Fix TestTopFieldCollectorEarlyTermination to ensure it has at least 1 none deleted document in the index

This commit is contained in:
Simon Willnauer 2017-12-07 15:47:28 +01:00
parent 68d16c2a65
commit a3141457d6
1 changed files with 2 additions and 3 deletions

View File

@ -96,7 +96,7 @@ public class TestTopFieldCollectorEarlyTermination extends LuceneTestCase {
iw.forceMerge(FORCE_MERGE_MAX_SEGMENT_COUNT);
}
reader = iw.getReader();
if (reader.maxDoc() == 0) {
if (reader.numDocs() == 0) {
iw.addDocument(new Document());
reader.close();
reader = iw.getReader();
@ -130,7 +130,7 @@ public class TestTopFieldCollectorEarlyTermination extends LuceneTestCase {
final int numHits = TestUtil.nextInt(random(), 1, numDocs);
FieldDoc after;
if (paging) {
assert searcher.getIndexReader().maxDoc() > 0;
assert searcher.getIndexReader().numDocs() > 0;
TopFieldDocs td = searcher.search(new MatchAllDocsQuery(), 10, sort);
after = (FieldDoc) td.scoreDocs[td.scoreDocs.length - 1];
} else {
@ -209,5 +209,4 @@ public class TestTopFieldCollectorEarlyTermination extends LuceneTestCase {
assertEquals(scoreDoc1.score, scoreDoc2.score, 0f);
}
}
}