Geo Hash Grid Aggregation
More info about geo hash grid aggregation is in the official elasticsearch docs
A multi-bucket aggregation that works on geo_point fields and groups points into buckets that represent cells in a grid.
Simple example
{
"aggregations" : {
"GrainGeoHashGrid" : {
"geohash_grid" : {
"field" : "location",
"precision" : 3
}
}
}
}
And now the query via DSL:
$geoHashGridAggregation = new GeoHashGridAggregation(
'GrainGeoHashGrid',
'location',
3
);
$search = new Search();
$search->addAggregation($geoHashGridAggregation);
$queryArray = $search->toArray();