diff options
author | Luca Cavanna <javanna@users.noreply.github.com> | 2017-02-27 15:42:25 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-02-27 15:42:25 +0100 |
commit | 2fb0466f669b030dfdd3cf0f876f4f4a98560781 (patch) | |
tree | 001d5827172b3b4101ee74f5cf041b8a15027881 /core/src/main/java/org/elasticsearch/search/suggest/completion | |
parent | 1ceaef0de63b75904faa8d77d962dea364e176d0 (diff) |
Convert suggestion response parsing to use NamedXContentRegistry (#23355)
We recently added parsing code to parse suggesters responses into java api objects. This was done using a switch based on the type of the returned suggestion. We can now replace the switch with using NamedXContentRegistry, which will also be used for aggs parsing.
Diffstat (limited to 'core/src/main/java/org/elasticsearch/search/suggest/completion')
-rw-r--r-- | core/src/main/java/org/elasticsearch/search/suggest/completion/CompletionSuggestion.java | 6 |
1 files changed, 6 insertions, 0 deletions
diff --git a/core/src/main/java/org/elasticsearch/search/suggest/completion/CompletionSuggestion.java b/core/src/main/java/org/elasticsearch/search/suggest/completion/CompletionSuggestion.java index ed45104d99..229b77aad2 100644 --- a/core/src/main/java/org/elasticsearch/search/suggest/completion/CompletionSuggestion.java +++ b/core/src/main/java/org/elasticsearch/search/suggest/completion/CompletionSuggestion.java @@ -94,6 +94,12 @@ public final class CompletionSuggestion extends Suggest.Suggestion<CompletionSug return getOptions().size() > 0; } + public static CompletionSuggestion fromXContent(XContentParser parser, String name) throws IOException { + CompletionSuggestion suggestion = new CompletionSuggestion(name, -1); + parseEntries(parser, suggestion, CompletionSuggestion.Entry::fromXContent); + return suggestion; + } + private static final class OptionPriorityQueue extends org.apache.lucene.util.PriorityQueue<Entry.Option> { private final Comparator<Suggest.Suggestion.Entry.Option> comparator; |