LUCENE-8520: Fix test by running query so it count total hits

This commit is contained in:
iverase 2018-10-05 08:59:34 +02:00
parent ace0db7a0a
commit 98b057c93a
1 changed files with 4 additions and 1 deletions

View File

@ -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: