Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix AbstractStringFieldDataTestCase tests to account for TotalHits lower bound #4270

Merged
merged 2 commits into from
Aug 21, 2022
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
import org.apache.lucene.search.SortField;
import org.apache.lucene.search.TermQuery;
import org.apache.lucene.search.TopFieldDocs;
import org.apache.lucene.search.TotalHits;
import org.apache.lucene.search.join.QueryBitSetProducer;
import org.apache.lucene.search.join.ScoreMode;
import org.apache.lucene.search.join.ToParentBlockJoinQuery;
Expand Down Expand Up @@ -340,7 +341,13 @@ public void testSortMissing(boolean first, boolean reverse) throws IOException {
randomBoolean() ? numDocs : randomIntBetween(10, numDocs),
new Sort(sortField)
);
assertEquals(numDocs, topDocs.totalHits.value);
// As of Lucene 9.0.0, totalHits may be a lower bound
if (topDocs.totalHits.relation == TotalHits.Relation.EQUAL_TO) {
assertEquals(numDocs, topDocs.totalHits.value);
} else {
assertTrue(1000 <= topDocs.totalHits.value);
assertTrue(numDocs >= topDocs.totalHits.value);
}
BytesRef previousValue = first ? null : reverse ? UnicodeUtil.BIG_TERM : new BytesRef();
for (int i = 0; i < topDocs.scoreDocs.length; ++i) {
final String docValue = searcher.doc(topDocs.scoreDocs[i].doc).get("value");
Expand Down