diff options
Diffstat (limited to 'core/src/main/java/org/elasticsearch/search/suggest/completion/context/CategoryContextMapping.java')
-rw-r--r-- | core/src/main/java/org/elasticsearch/search/suggest/completion/context/CategoryContextMapping.java | 13 |
1 files changed, 8 insertions, 5 deletions
diff --git a/core/src/main/java/org/elasticsearch/search/suggest/completion/context/CategoryContextMapping.java b/core/src/main/java/org/elasticsearch/search/suggest/completion/context/CategoryContextMapping.java index 150b7bf4f9..38e31ec92a 100644 --- a/core/src/main/java/org/elasticsearch/search/suggest/completion/context/CategoryContextMapping.java +++ b/core/src/main/java/org/elasticsearch/search/suggest/completion/context/CategoryContextMapping.java @@ -107,21 +107,24 @@ public class CategoryContextMapping extends ContextMapping<CategoryQueryContext> * </ul> */ @Override - public Set<CharSequence> parseContext(ParseContext parseContext, XContentParser parser) throws IOException, ElasticsearchParseException { + public Set<CharSequence> parseContext(ParseContext parseContext, XContentParser parser) + throws IOException, ElasticsearchParseException { final Set<CharSequence> contexts = new HashSet<>(); Token token = parser.currentToken(); - if (token == Token.VALUE_STRING) { + if (token == Token.VALUE_STRING || token == Token.VALUE_NUMBER || token == Token.VALUE_BOOLEAN) { contexts.add(parser.text()); } else if (token == Token.START_ARRAY) { while ((token = parser.nextToken()) != Token.END_ARRAY) { - if (token == Token.VALUE_STRING) { + if (token == Token.VALUE_STRING || token == Token.VALUE_NUMBER || token == Token.VALUE_BOOLEAN) { contexts.add(parser.text()); } else { - throw new ElasticsearchParseException("context array must have string values"); + throw new ElasticsearchParseException( + "context array must have string, number or boolean values, but was [" + token + "]"); } } } else { - throw new ElasticsearchParseException("contexts must be a string or a list of strings"); + throw new ElasticsearchParseException( + "contexts must be a string, number or boolean or a list of string, number or boolean, but was [" + token + "]"); } return contexts; } |