mirror of https://github.com/apache/lucene.git
LUCENE-8520: Fix test by running query so it count total hits
This commit is contained in:
parent
ace0db7a0a
commit
98b057c93a
|
@ -29,6 +29,7 @@ import org.apache.lucene.search.Sort;
|
|||
import org.apache.lucene.search.SortField;
|
||||
import org.apache.lucene.search.TermQuery;
|
||||
import org.apache.lucene.search.TopDocs;
|
||||
import org.apache.lucene.search.TopScoreDocCollector;
|
||||
import org.apache.lucene.store.Directory;
|
||||
import org.apache.lucene.store.FilterDirectory;
|
||||
import org.apache.lucene.store.MockDirectoryWrapper;
|
||||
|
@ -67,7 +68,9 @@ public class TestIndexWriterMaxDocs extends LuceneTestCase {
|
|||
assertEquals(IndexWriter.MAX_DOCS, ir.maxDoc());
|
||||
assertEquals(IndexWriter.MAX_DOCS, ir.numDocs());
|
||||
IndexSearcher searcher = new IndexSearcher(ir);
|
||||
TopDocs hits = searcher.search(new TermQuery(new Term("field", "text")), 10);
|
||||
TopScoreDocCollector collector = TopScoreDocCollector.create(10, Integer.MAX_VALUE);
|
||||
searcher.search(new TermQuery(new Term("field", "text")), collector);
|
||||
TopDocs hits = collector.topDocs();
|
||||
assertEquals(IndexWriter.MAX_DOCS, hits.totalHits.value);
|
||||
|
||||
// Sort by docID reversed:
|
||||
|
|
Loading…
Reference in New Issue