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

Aggregations: ClassCastException when sibling aggregations have the same name #6255

Closed
colings86 opened this issue May 21, 2014 · 3 comments · Fixed by #6258
Closed

Aggregations: ClassCastException when sibling aggregations have the same name #6255

colings86 opened this issue May 21, 2014 · 3 comments · Fixed by #6258

Comments

@colings86
Copy link
Contributor

If I run a search query of the following kind:

curl -XGET 'http://localhost:9200/index/_search?pretty' -d '{ "query" : { "match_all" : {} }, "aggs" : { "agg1" : { "terms" : { "field" : "stringField" } }, "agg1" : { "terms" : { "field" : "longField" } } } }'

It causes a ClassCastException in Elasticsearch:

{
  "error" : "ClassCastException[org.elasticsearch.search.aggregations.bucket.terms.LongTerms$Bucket cannot be cast to org.elasticsearch.search.aggregations.bucket.terms.StringTerms$Bucket]",
  "status" : 500
}

It looks like it is actually combining all aggregations with the same name into one combined aggregation. The error occurs when the fields in the two aggregations are different types but will also give strange results when they are both the same type. I have so far only tried this with the Terms aggregation but I suspect it will be an issue for other types too.

There should probably be some validation of sibling aggregations to ensure they have unique names and throw back a parse error to the client if there are multiple sibling aggregations with the same name.

More than this, since aggregations can be referenced from other aggregations by name, should aggregations names be unique across all aggregations and not just within their siblings?

@colings86 colings86 added the bug label May 21, 2014
@jpountz
Copy link
Contributor

jpountz commented May 21, 2014

There should probably be some validation of sibling aggregations to ensure they have unique names and throw back a parse error to the client if there are multiple sibling aggregations with the same name.

+1 I'll work on that

@jpountz
Copy link
Contributor

jpountz commented May 21, 2014

More than this, since aggregations can be referenced from other aggregations by name, should aggregations names be unique across all aggregations and not just within their siblings?

When referring to another aggregation (eg. for sorting the buckets of a terms aggregation), you need to specify the relative path from the current aggregation to the one that is used for sorting, so there should be no ambiguity. Or were you thinking about something else?

@colings86
Copy link
Contributor Author

No, that is what I was thinking of, so its just a problem for sibling aggregations then

jpountz added a commit to jpountz/elasticsearch that referenced this issue May 21, 2014
@clintongormley clintongormley changed the title ClassCastException when sibling aggregations have the same name Aggregations: ClassCastException when sibling aggregations have the same name Jul 16, 2014
mute pushed a commit to mute/elasticsearch that referenced this issue Jul 29, 2015
mute pushed a commit to mute/elasticsearch that referenced this issue Jul 29, 2015
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants