Geo centroid aggregation
/ Geo_centroid, / AggregationGeo centroid aggregation #
A metrics aggregation computing the centroid (mean latitude and
longitude) of all geo_point values.
How it works #
The engine sums latitudes and longitudes across the bucket’s
geo_point values and divides by the count:
{
"location": { "lat": .., "lon": .. },
"count": 15
}
- The mean is arithmetic per axis (a planar average, not spherical) — exact enough at city or country scale, drifting only for extents that cross the 180th meridian or span hemispheres.
- Every parseable point counts once; there is no weight field. The
result is
nullwhen the bucket holds no points. - Under distributed fan-out the coordinator keeps its own shard’s value (geo metrics have no mergeable intermediate), so single-node results are the exact ones.
- Like every
geo_pointconsumer, the aggregation sees points normalized at ingestion:{"lat": .., "lon": ..},[lon, lat](longitude first) or a"lat,lon"string, all stored as two-dimensional BKD points.
Examples #
Returns the count of points and their centroid — the natural center
point for map placement. Over the 15 places: count: 15, location
about {lat 31.7484, lon 111.2181}.