Skip to content

Commit 79c76a8

Browse files
Fix flaky test
Signed-off-by: Prudhvi Godithi <[email protected]>
1 parent ae78944 commit 79c76a8

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

server/src/internalClusterTest/java/org/opensearch/search/simple/SimpleSearchIT.java

+8-1
Original file line numberDiff line numberDiff line change
@@ -432,7 +432,14 @@ public void doTestSimpleTerminateAfterTrackTotalHitsUpTo(int size) throws Except
432432
.setTrackTotalHitsUpTo(5)
433433
.get();
434434
assertEquals(5, searchResponse.getHits().getTotalHits().value());
435-
assertEquals(GREATER_THAN_OR_EQUAL_TO, searchResponse.getHits().getTotalHits().relation());
435+
// With approximation on LONG fields, if size < trackTotalHitsUpTo (5), we can efficiently determine the exact count and return
436+
// EQUAL_TO relation.
437+
System.out.println("The size is " + size);
438+
if (size <= 5) {
439+
assertEquals(EQUAL_TO, searchResponse.getHits().getTotalHits().relation());
440+
} else {
441+
assertEquals(GREATER_THAN_OR_EQUAL_TO, searchResponse.getHits().getTotalHits().relation());
442+
}
436443
}
437444

438445
public void testSimpleTerminateAfterTrackTotalHitsUpToRandomSize0() throws Exception {

0 commit comments

Comments
 (0)