Can I aggregate ElasticSearch results by geo_polygon?


(Ariutk) #1

I have an ElasticSearch query that returns stats about items in a single geo_polygon (number of matches, averages/totals etc.)

Is it possible to modify the query to send a list of polygons, with the results aggregated by geo_polygon?


(Colin Goodheart-Smithe) #2

you could use the filters aggregation and specify a geo filter for each of your polygons. Then you could have your statistics (I am assuming you are using aggregations to generate them) as sub-aggregations of this filters aggregation.

See the following for more information on the filters aggregation: https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-filters-aggregation.html


(system) #3