-
Notifications
You must be signed in to change notification settings - Fork 25.1k
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
sub aggregations can overwrite bucket fields #17652
Comments
To change this we would require #11184 to be done first |
cc @elastic/es-search-aggs |
We discussed this issue on 2020-08-19, and have decided not to fix it. We believe this to be a rare issue, based on the fact that it's been open for years and has no upvotes. Also, a user has to go out of their way to hit this, and the resulting failure is relatively obvious. On the other hand, fixing it either requires a huge breaking change to how aggregation results are formatted, or requires us to maintain a list of forbidden aggregation names, which would be a breaking change every time we added to it. Neither option is appealing. Based on this analysis, we feel making any change here would cause more harm than the bug is currently causing. |
I'm removing the breaking label so this stops showing up in searches for breaking changes. |
Consider the following sense script:
The sub aggregations to the terms aggregation are named
key
anddoc_count
. In the response these sub-aggregations overwrite thekey
anddoc_count
fields of the bucket (for comparison the normal response without any sub aggregations is at the bottom of this bug report):Sub aggregations should not be able to overwrite fields in the bucket. Note that this affects all bucket aggregations and other bucket aggregations use other fields. More generally a bucket aggregation has (and should have) no restrictions on the fields it can use in each bucket response.
We should not fix this by not allowing aggregations to be named
doc_count
orkey
, etc. That would be a hacky fix that would be hard to maintain (if a bucket aggregation defines a new field in the bucket we would have to remember to add it to the exceptions which is easily missed).I think we should solve this by name-spacing the sub aggregations under an
aggregations
object in the bucket. This would make the output safer (and avoid this bug), and would match the request format better (where sub aggregations are nested under anaggs
/aggregations
object). This would obviously be a breaking change but I think it is an important change to make. If we implement #11184 we could effectively deprecate the old response format by having it output the new format by default but output the old format if the version parameter is specified on the request (with a version number relevant for the old format). Then we could remove the old format in the next major version.Response with no sub-aggregations:
The text was updated successfully, but these errors were encountered: