Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More lenient type parsing in histo/cardinality aggs #6948

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
Expand Up @@ -65,16 +65,12 @@ public AggregatorFactory parse(String aggregationName, XContentParser parser, Se
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();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

To coerce, should be:

parser.longValue(true);

} 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 + "].");
Expand Down
Expand Up @@ -56,14 +56,10 @@ public AggregatorFactory parse(String name, XContentParser parser, SearchContext
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();

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same here:

 parser.longValue(true);

} else {
throw new SearchParseException(context, "Unknown key for a " + token + " in [" + name + "]: [" + currentFieldName + "].");
Expand Down