Skip to content

Commit 77dc7f8

Browse files
committed
fix totalHits expectation in test
1 parent 832db29 commit 77dc7f8

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

server/src/test/java/org/elasticsearch/search/query/QueryPhaseTests.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,7 @@
5555
import org.apache.lucene.search.TermQuery;
5656
import org.apache.lucene.search.TopDocs;
5757
import org.apache.lucene.search.TotalHits;
58+
import org.apache.lucene.search.TotalHits.Relation;
5859
import org.apache.lucene.search.Weight;
5960
import org.apache.lucene.search.join.BitSetProducer;
6061
import org.apache.lucene.search.join.ScoreMode;
@@ -969,6 +970,7 @@ private static void assertSortResults(TopDocs topDocs, long totalNumDocs, boolea
969970
}
970971
}
971972

973+
@com.carrotsearch.randomizedtesting.annotations.Repeat(iterations = 10)
972974
public void testMinScore() throws Exception {
973975
IndexWriterConfig iwc = newIndexWriterConfig();
974976
RandomIndexWriter w = new RandomIndexWriter(random(), dir, iwc);
@@ -990,7 +992,10 @@ public void testMinScore() throws Exception {
990992
context.trackTotalHitsUpTo(5);
991993

992994
QueryPhase.addCollectorsAndSearch(context);
993-
assertEquals(10, context.queryResult().topDocs().topDocs.totalHits.value());
995+
TotalHits totalHits = context.queryResult().topDocs().topDocs.totalHits;
996+
assertThat(totalHits.value(), greaterThanOrEqualTo(5L));
997+
var expectedRelation = totalHits.value() == 10 ? Relation.EQUAL_TO : Relation.GREATER_THAN_OR_EQUAL_TO;
998+
assertThat(totalHits.relation(), is(expectedRelation));
994999
}
9951000
}
9961001

0 commit comments

Comments
 (0)