diff --git a/src/main/java/org/elasticsearch/search/aggregations/bucket/histogram/HistogramParser.java b/src/main/java/org/elasticsearch/search/aggregations/bucket/histogram/HistogramParser.java index 98e010ff215..ac0e25b113b 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/bucket/histogram/HistogramParser.java +++ b/src/main/java/org/elasticsearch/search/aggregations/bucket/histogram/HistogramParser.java @@ -65,16 +65,12 @@ public class HistogramParser implements Aggregator.Parser { currentFieldName = parser.currentName(); } else if (vsParser.token(currentFieldName, token, parser)) { continue; - } else if (token == XContentParser.Token.VALUE_NUMBER) { + } else if (token.isValue()) { if ("interval".equals(currentFieldName)) { interval = parser.longValue(); } else if ("min_doc_count".equals(currentFieldName) || "minDocCount".equals(currentFieldName)) { minDocCount = parser.longValue(); - } else { - throw new SearchParseException(context, "Unknown key for a " + token + " in aggregation [" + aggregationName + "]: [" + currentFieldName + "]."); - } - } else if (token == XContentParser.Token.VALUE_BOOLEAN) { - if ("keyed".equals(currentFieldName)) { + } else if ("keyed".equals(currentFieldName)) { keyed = parser.booleanValue(); } else { throw new SearchParseException(context, "Unknown key for a " + token + " in aggregation [" + aggregationName + "]: [" + currentFieldName + "]."); diff --git a/src/main/java/org/elasticsearch/search/aggregations/metrics/cardinality/CardinalityParser.java b/src/main/java/org/elasticsearch/search/aggregations/metrics/cardinality/CardinalityParser.java index 8b176b5ee25..7677ca1e33b 100644 --- a/src/main/java/org/elasticsearch/search/aggregations/metrics/cardinality/CardinalityParser.java +++ b/src/main/java/org/elasticsearch/search/aggregations/metrics/cardinality/CardinalityParser.java @@ -56,14 +56,10 @@ public class CardinalityParser implements Aggregator.Parser { currentFieldName = parser.currentName(); } else if (vsParser.token(currentFieldName, token, parser)) { continue; - } else if (token == XContentParser.Token.VALUE_BOOLEAN) { + } else if (token.isValue()) { if ("rehash".equals(currentFieldName)) { rehash = parser.booleanValue(); - } else { - throw new SearchParseException(context, "Unknown key for a " + token + " in [" + name + "]: [" + currentFieldName + "]."); - } - } else if (token == XContentParser.Token.VALUE_NUMBER) { - if (PRECISION_THRESHOLD.match(currentFieldName)) { + } else if (PRECISION_THRESHOLD.match(currentFieldName)) { precisionThreshold = parser.longValue(); } else { throw new SearchParseException(context, "Unknown key for a " + token + " in [" + name + "]: [" + currentFieldName + "].");