diff --git a/lucene/queries/src/java/org/apache/lucene/queries/CommonTermsQuery.java b/lucene/queries/src/java/org/apache/lucene/queries/CommonTermsQuery.java index d730e8a7cfd..53ed403fdfe 100644 --- a/lucene/queries/src/java/org/apache/lucene/queries/CommonTermsQuery.java +++ b/lucene/queries/src/java/org/apache/lucene/queries/CommonTermsQuery.java @@ -157,10 +157,7 @@ public class CommonTermsQuery extends Query { final TermContext[] contextArray = new TermContext[terms.size()]; final Term[] queryTerms = this.terms.toArray(new Term[0]); collectTermContext(reader, leaves, contextArray, queryTerms); - Query q = buildQuery(maxDoc, contextArray, queryTerms); - System.out.println(reader); - System.out.println(q); - return q; + return buildQuery(maxDoc, contextArray, queryTerms); } protected Query buildQuery(final int maxDoc, @@ -175,20 +172,15 @@ public class CommonTermsQuery extends Query { BooleanQuery query = new BooleanQuery(true); for (int i = 0; i < queryTerms.length; i++) { TermContext termContext = contextArray[i]; - if (termContext == null) { - System.out.println("term: " + queryTerms[i] + " context: " + -1 + " maxTermFrequency: " + maxTermFrequency + " LOW"); - lowFreq.add(new TermQuery(queryTerms[i]), lowFreqOccur); } else { if ((maxTermFrequency >= 1f && termContext.docFreq() > maxTermFrequency) || (termContext.docFreq() > (int) Math.ceil(maxTermFrequency * (float) maxDoc))) { - System.out.println("term: " + queryTerms[i] + " context: " + termContext.docFreq() + " maxTermFrequency: " + maxTermFrequency + " HIGH"); highFreq .add(new TermQuery(queryTerms[i], termContext), highFreqOccur); } else { - System.out.println("term: " + queryTerms[i] + " context: " + termContext.docFreq() + " maxTermFrequency: " + maxTermFrequency + " LOW"); lowFreq.add(new TermQuery(queryTerms[i], termContext), lowFreqOccur); } } @@ -265,6 +257,8 @@ public class CommonTermsQuery extends Query { * Returns true iff {@link Similarity#coord(int,int)} is disabled in scoring * for the high and low frequency query instance. The top level query will * always disable coords. + * + * @see #CommonTermsQuery(Occur, Occur, float, boolean) */ public boolean isCoordDisabled() { return disableCoord; diff --git a/lucene/queries/src/test/org/apache/lucene/queries/CommonTermsQueryTest.java b/lucene/queries/src/test/org/apache/lucene/queries/CommonTermsQueryTest.java index ba3bc63de7a..c551de72fb5 100644 --- a/lucene/queries/src/test/org/apache/lucene/queries/CommonTermsQueryTest.java +++ b/lucene/queries/src/test/org/apache/lucene/queries/CommonTermsQueryTest.java @@ -263,6 +263,7 @@ public class CommonTermsQueryTest extends LuceneTestCase { } TopDocs cqSearch = searcher.search(cq, reader.maxDoc()); + QueryUtils.check(random(), cq, searcher); TopDocs verifySearch = searcher.search(verifyQuery, reader.maxDoc()); assertEquals(verifySearch.totalHits, cqSearch.totalHits); @@ -276,18 +277,6 @@ public class CommonTermsQueryTest extends LuceneTestCase { } assertTrue(hits.isEmpty()); - - /* - * need to force merge here since QueryUtils adds checks based - * on leave readers which have different statistics than the top - * level reader if we have more than one segment. This could - * result in a different query / results. - */ - w.forceMerge(1); - DirectoryReader reader2 = w.getReader(); - QueryUtils.check(random(), cq, newSearcher(reader2)); - reader2.close(); - } finally { reader.close(); wrapper.close();