diff --git a/core/src/main/java/org/elasticsearch/search/suggest/completion/CompletionSuggester.java b/core/src/main/java/org/elasticsearch/search/suggest/completion/CompletionSuggester.java index 38b3d4b4202..5690acd7abd 100644 --- a/core/src/main/java/org/elasticsearch/search/suggest/completion/CompletionSuggester.java +++ b/core/src/main/java/org/elasticsearch/search/suggest/completion/CompletionSuggester.java @@ -58,8 +58,8 @@ public class CompletionSuggester extends Suggester CompletionSuggestion.Entry completionSuggestEntry = new CompletionSuggestion.Entry( new Text(spare.toString()), 0, spare.length()); completionSuggestion.addTerm(completionSuggestEntry); - TopSuggestDocsCollector collector = - new TopDocumentsCollector(suggestionContext.getSize(), suggestionContext.isSkipDuplicates()); + int shardSize = suggestionContext.getShardSize() != null ? suggestionContext.getShardSize() : suggestionContext.getSize(); + TopSuggestDocsCollector collector = new TopDocumentsCollector(shardSize, suggestionContext.isSkipDuplicates()); suggest(searcher, suggestionContext.toQuery(), collector); int numResult = 0; for (TopSuggestDocs.SuggestScoreDoc suggestScoreDoc : collector.get().scoreLookupDocs()) { diff --git a/core/src/main/java/org/elasticsearch/search/suggest/completion/CompletionSuggestionBuilder.java b/core/src/main/java/org/elasticsearch/search/suggest/completion/CompletionSuggestionBuilder.java index 468a7d21fc5..026dc45a120 100644 --- a/core/src/main/java/org/elasticsearch/search/suggest/completion/CompletionSuggestionBuilder.java +++ b/core/src/main/java/org/elasticsearch/search/suggest/completion/CompletionSuggestionBuilder.java @@ -289,6 +289,9 @@ public class CompletionSuggestionBuilder extends SuggestionBuilder