Skip to content

[8.19] Fix bug with multiple spatial aggs filtering in ES|QL (#142332) (#142385) (#142487)#142533

Merged
elasticsearchmachine merged 1 commit intoelastic:8.19from
craigtaverner:backport/8.19/pr-142487
Feb 16, 2026
Merged

[8.19] Fix bug with multiple spatial aggs filtering in ES|QL (#142332) (#142385) (#142487)#142533
elasticsearchmachine merged 1 commit intoelastic:8.19from
craigtaverner:backport/8.19/pr-142487

Conversation

@craigtaverner
Copy link
Copy Markdown
Contributor

elastic#142385) (elastic#142487)

When using a WHERE clause within the STATS of a spatial aggregation, and there are more than one aggregation function, the results are incorrect, and reflect the values of the first aggregating function. With some investigation by Cursor it turns out this is a side effect of the fact that the replaceChildren function was not capturing the filter (and not the window or field-extract preference either). This was probably due to the first implementation of the filter in elastic#113735 back in October 2024, which appears to have not updated this method in the SpatialCentroid class, although it did update that method in other aggregations. Then SpatialExtents, inspired by SpatialCentroid code, inherited this flaw. Since it is rare to perform queries like this, and our test suite did not include any, we did not notice this until working on a more advanced feature, extracting a combination of both centroid and bounds from shape doc-values, which requires both centroid and shape aggregations in the same query.
@craigtaverner craigtaverner added :Analytics/ES|QL AKA ESQL >bug auto-merge-without-approval Automatically merge pull request when CI checks pass (NB doesn't wait for reviews!) backport Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) labels Feb 16, 2026
@elasticsearchmachine elasticsearchmachine merged commit 0b09072 into elastic:8.19 Feb 16, 2026
28 checks passed
@craigtaverner craigtaverner deleted the backport/8.19/pr-142487 branch February 16, 2026 10:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

:Analytics/ES|QL AKA ESQL auto-merge-without-approval Automatically merge pull request when CI checks pass (NB doesn't wait for reviews!) backport >bug Team:Analytics Meta label for analytical engine team (ESQL/Aggs/Geo) v8.19.12

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants