"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "lucene/queries/src/java/org/apache/lucene/queries/CommonTermsQuery.java" between
lucene-9.6.0-src.tgz and lucene-9.7.0-src.tgz

About: Lucene is a Java full-text search engine (not a complete application, but rather a code library and API). Java source code.
The most recent release (9.x series).

CommonTermsQuery.java  (lucene-9.6.0-src.tgz):CommonTermsQuery.java  (lucene-9.7.0-src.tgz)
skipping to change at line 33 skipping to change at line 33
import java.util.Objects; import java.util.Objects;
import org.apache.lucene.index.IndexReader; import org.apache.lucene.index.IndexReader;
import org.apache.lucene.index.LeafReaderContext; import org.apache.lucene.index.LeafReaderContext;
import org.apache.lucene.index.Term; import org.apache.lucene.index.Term;
import org.apache.lucene.index.TermStates; import org.apache.lucene.index.TermStates;
import org.apache.lucene.index.Terms; import org.apache.lucene.index.Terms;
import org.apache.lucene.index.TermsEnum; import org.apache.lucene.index.TermsEnum;
import org.apache.lucene.search.BooleanClause.Occur; import org.apache.lucene.search.BooleanClause.Occur;
import org.apache.lucene.search.BooleanQuery; import org.apache.lucene.search.BooleanQuery;
import org.apache.lucene.search.BoostQuery; import org.apache.lucene.search.BoostQuery;
import org.apache.lucene.search.IndexSearcher;
import org.apache.lucene.search.MatchNoDocsQuery; import org.apache.lucene.search.MatchNoDocsQuery;
import org.apache.lucene.search.Query; import org.apache.lucene.search.Query;
import org.apache.lucene.search.QueryVisitor; import org.apache.lucene.search.QueryVisitor;
import org.apache.lucene.search.TermQuery; import org.apache.lucene.search.TermQuery;
/** /**
* A query that executes high-frequency terms in a optional sub-query to prevent slow queries due to * A query that executes high-frequency terms in a optional sub-query to prevent slow queries due to
* "common" terms like stopwords. This query builds 2 queries off the {@link #ad d(Term) added} * "common" terms like stopwords. This query builds 2 queries off the {@link #ad d(Term) added}
* terms: low-frequency terms are added to a required boolean clause and high-fr equency terms are * terms: low-frequency terms are added to a required boolean clause and high-fr equency terms are
* added to an optional boolean clause. The optional clause is only executed if the required * added to an optional boolean clause. The optional clause is only executed if the required
skipping to change at line 104 skipping to change at line 105
* @param term the term to add * @param term the term to add
*/ */
public void add(Term term) { public void add(Term term) {
if (term == null) { if (term == null) {
throw new IllegalArgumentException("Term must not be null"); throw new IllegalArgumentException("Term must not be null");
} }
this.terms.add(term); this.terms.add(term);
} }
@Override @Override
public Query rewrite(IndexReader reader) throws IOException { public Query rewrite(IndexSearcher indexSearcher) throws IOException {
IndexReader reader = indexSearcher.getIndexReader();
if (this.terms.isEmpty()) { if (this.terms.isEmpty()) {
return new MatchNoDocsQuery("CommonTermsQuery with no terms"); return new MatchNoDocsQuery("CommonTermsQuery with no terms");
} else if (this.terms.size() == 1) { } else if (this.terms.size() == 1) {
return newTermQuery(this.terms.get(0), null); return newTermQuery(this.terms.get(0), null);
} }
final List<LeafReaderContext> leaves = reader.leaves(); final List<LeafReaderContext> leaves = reader.leaves();
final int maxDoc = reader.maxDoc(); final int maxDoc = reader.maxDoc();
final TermStates[] contextArray = new TermStates[terms.size()]; final TermStates[] contextArray = new TermStates[terms.size()];
final Term[] queryTerms = this.terms.toArray(new Term[0]); final Term[] queryTerms = this.terms.toArray(new Term[0]);
collectTermStates(reader, leaves, contextArray, queryTerms); collectTermStates(reader, leaves, contextArray, queryTerms);
 End of changes. 2 change blocks. 
1 lines changed or deleted 3 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)