Fix geo_centroid over geo_shape merging multiple shards#144637
Open
craigtaverner wants to merge 13 commits intoelastic:mainfrom
Open
Fix geo_centroid over geo_shape merging multiple shards#144637craigtaverner wants to merge 13 commits intoelastic:mainfrom
craigtaverner wants to merge 13 commits intoelastic:mainfrom
Conversation
Collaborator
|
Pinging @elastic/es-analytical-engine (Team:Analytics) |
Collaborator
|
Hi @craigtaverner, I've created a changelog YAML for you. |
craigtaverner
commented
Mar 20, 2026
...ernalClusterTest/java/org/elasticsearch/xpack/esql/spatial/SpatialPushDownShapeTestCase.java
Outdated
Show resolved
Hide resolved
Collaborator
|
Hi @craigtaverner, I've updated the changelog YAML for you. |
Was part of early investigations only
…csearch into fix_centroid_shards
Contributor
|
I would expect this to have some BWC side effects? |
iverase
reviewed
Mar 20, 2026
| protected final double firstWeightedSum; | ||
| protected final double secondWeightedSum; | ||
| protected final double totalWeight; | ||
| protected final DimensionalShapeType shapeType; |
Contributor
There was a problem hiding this comment.
Can we add this as a record that is null (or a constant) for points? I want to make the canonical footprint of this object smaller as we can be thousands of those objects on heap.
Contributor
Author
There was a problem hiding this comment.
Great idea. I've done that now, with a record that we set to null for points.
…csearch into fix_centroid_shards
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
As described in #144504 we are seeing different results between
geo_centroidin QueryDSL and ES|QL'sST_CENTROID_AGGwhen the data isgeo_shape(or cartesian shapes). The root cause turned out to be thatgeo_centriodwas using point-only logic for merging intermediate aggregation results between shards, which means it was considering doc-count only for the weighted merge, and missing:This PR contains appropriate unit tests, but manual testing on the OSM dataset we used in the benchmarking leads to:
Note: the small deviations on the 15th and 16th decimal point of the ES|QL results actually occur when simply re-running the same query over and over and are likely a result of floating point errors related to the order in which results are added to the Kahan summation and are not related to the fixes.
Fixes #144504