Skip to content

Commit a4f4525

Browse files
authored
Merge pull request elastic#19969 from chengpohi/master
fix CompletionSuggestion test failed caused by shard is 1
2 parents 8e5ee2c + 77f28db commit a4f4525

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

core/src/test/java/org/elasticsearch/search/suggest/completion/CompletionSuggestionTests.java

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,7 +32,6 @@
3232

3333
public class CompletionSuggestionTests extends ESTestCase {
3434

35-
@AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/19896")
3635
public void testToReduce() throws Exception {
3736
List<Suggest.Suggestion<CompletionSuggestion.Entry>> shardSuggestions = new ArrayList<>();
3837
int nShards = randomIntBetween(1, 10);
@@ -47,8 +46,11 @@ public void testToReduce() throws Exception {
4746
float maxScore = randomIntBetween(totalResults, totalResults*2);
4847
for (int i = 0; i < totalResults; i++) {
4948
Suggest.Suggestion<CompletionSuggestion.Entry> suggestion = randomFrom(shardSuggestions);
50-
suggestion.getEntries().get(0).addOption(new CompletionSuggestion.Entry.Option(i, new Text(""),
51-
maxScore - i, Collections.emptyMap()));
49+
CompletionSuggestion.Entry entry = suggestion.getEntries().get(0);
50+
if (entry.getOptions().size() < size) {
51+
entry.addOption(new CompletionSuggestion.Entry.Option(i, new Text(""),
52+
maxScore - i, Collections.emptyMap()));
53+
}
5254
}
5355
CompletionSuggestion reducedSuggestion = CompletionSuggestion.reduceTo(shardSuggestions);
5456
assertNotNull(reducedSuggestion);

0 commit comments

Comments
 (0)