Skip to content

Commit 5df1f80

Browse files
Fix flaky testMaxScoreWithSortOnScoreAndCollapsingResults (#19513)
* fix flaky testMaxScoreWithSortOnScoreAndCollapsingResults Signed-off-by: bowenlan-amzn <[email protected]> * fix flaky testMaxScoreWithSortOnScoreAndCollapsingResults Signed-off-by: bowenlan-amzn <[email protected]> --------- Signed-off-by: bowenlan-amzn <[email protected]>
1 parent 4094287 commit 5df1f80

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1090,7 +1090,8 @@ public void testMaxScore() throws Exception {
10901090

10911091
public void testMaxScoreWithSortOnScoreAndCollapsingResults() throws Exception {
10921092
Directory dir = newDirectory();
1093-
IndexWriterConfig iwc = newIndexWriterConfig();
1093+
final Sort sort = new Sort(new SortField("user", SortField.Type.INT));
1094+
IndexWriterConfig iwc = newIndexWriterConfig().setIndexSort(sort);
10941095
RandomIndexWriter w = new RandomIndexWriter(random(), dir, iwc);
10951096

10961097
// Always end up with uneven buckets so collapsing is predictable
@@ -1130,8 +1131,8 @@ public void testMaxScoreWithSortOnScoreAndCollapsingResults() throws Exception {
11301131

11311132
assertThat(context.queryResult().topDocs().topDocs.scoreDocs[0].score, equalTo(context.queryResult().getMaxScore()));
11321133

1133-
Sort sort = new Sort(new SortField(null, SortField.Type.SCORE), new SortField(null, SortField.Type.DOC));
1134-
SortAndFormats sortAndFormats = new SortAndFormats(sort, new DocValueFormat[] { DocValueFormat.RAW, DocValueFormat.RAW });
1134+
Sort scoreSort = new Sort(new SortField(null, SortField.Type.SCORE), new SortField(null, SortField.Type.DOC));
1135+
SortAndFormats sortAndFormats = new SortAndFormats(scoreSort, new DocValueFormat[] { DocValueFormat.RAW, DocValueFormat.RAW });
11351136
context.sort(sortAndFormats);
11361137
QueryPhase.executeInternal(context.withCleanQueryResult(), queryPhaseSearcher);
11371138
assertFalse(Float.isNaN(context.queryResult().getMaxScore()));

0 commit comments

Comments
 (0)