mirror of https://github.com/apache/lucene.git
LUCENE-8464: Fix legacy.TestMultiValuedNumericRangeQuery to count the number of hits accurately
This commit is contained in:
parent
a0788a7b5e
commit
759af0127c
|
@ -29,6 +29,7 @@ import org.apache.lucene.index.RandomIndexWriter;
|
|||
import org.apache.lucene.search.IndexSearcher;
|
||||
import org.apache.lucene.search.TermRangeQuery;
|
||||
import org.apache.lucene.search.TopDocs;
|
||||
import org.apache.lucene.search.TopScoreDocCollector;
|
||||
import org.apache.lucene.store.Directory;
|
||||
import org.apache.lucene.util.LuceneTestCase;
|
||||
import org.apache.lucene.util.TestUtil;
|
||||
|
@ -71,8 +72,12 @@ public class TestMultiValuedNumericRangeQuery extends LuceneTestCase {
|
|||
}
|
||||
TermRangeQuery cq=TermRangeQuery.newStringRange("asc", format.format(lower), format.format(upper), true, true);
|
||||
LegacyNumericRangeQuery<Integer> tq= LegacyNumericRangeQuery.newIntRange("trie", lower, upper, true, true);
|
||||
TopDocs trTopDocs = searcher.search(cq, 1);
|
||||
TopDocs nrTopDocs = searcher.search(tq, 1);
|
||||
TopScoreDocCollector trCollector = TopScoreDocCollector.create(1, Integer.MAX_VALUE);
|
||||
TopScoreDocCollector nrCollector = TopScoreDocCollector.create(1, Integer.MAX_VALUE);
|
||||
searcher.search(cq, trCollector);
|
||||
searcher.search(tq, nrCollector);
|
||||
TopDocs trTopDocs = trCollector.topDocs();
|
||||
TopDocs nrTopDocs = nrCollector.topDocs();
|
||||
assertEquals("Returned count for LegacyNumericRangeQuery and TermRangeQuery must be equal", trTopDocs.totalHits.value, nrTopDocs.totalHits.value );
|
||||
}
|
||||
reader.close();
|
||||
|
|
Loading…
Reference in New Issue