From 77f28dbdde3cd58a59711b32d080c2745370d4db Mon Sep 17 00:00:00 2001 From: Xiang Chen Date: Fri, 12 Aug 2016 09:23:17 +0800 Subject: [PATCH] fix CompletionSuggestion test failed caused by shard is 1 --- .../suggest/completion/CompletionSuggestionTests.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/core/src/test/java/org/elasticsearch/search/suggest/completion/CompletionSuggestionTests.java b/core/src/test/java/org/elasticsearch/search/suggest/completion/CompletionSuggestionTests.java index 1f2c14ba00d..60722fb5f6d 100644 --- a/core/src/test/java/org/elasticsearch/search/suggest/completion/CompletionSuggestionTests.java +++ b/core/src/test/java/org/elasticsearch/search/suggest/completion/CompletionSuggestionTests.java @@ -32,7 +32,6 @@ import static org.hamcrest.Matchers.lessThanOrEqualTo; public class CompletionSuggestionTests extends ESTestCase { - @AwaitsFix(bugUrl = "https://github.com/elastic/elasticsearch/issues/19896") public void testToReduce() throws Exception { List> shardSuggestions = new ArrayList<>(); int nShards = randomIntBetween(1, 10); @@ -47,8 +46,11 @@ public class CompletionSuggestionTests extends ESTestCase { float maxScore = randomIntBetween(totalResults, totalResults*2); for (int i = 0; i < totalResults; i++) { Suggest.Suggestion suggestion = randomFrom(shardSuggestions); - suggestion.getEntries().get(0).addOption(new CompletionSuggestion.Entry.Option(i, new Text(""), - maxScore - i, Collections.emptyMap())); + CompletionSuggestion.Entry entry = suggestion.getEntries().get(0); + if (entry.getOptions().size() < size) { + entry.addOption(new CompletionSuggestion.Entry.Option(i, new Text(""), + maxScore - i, Collections.emptyMap())); + } } CompletionSuggestion reducedSuggestion = CompletionSuggestion.reduceTo(shardSuggestions); assertNotNull(reducedSuggestion);