# Does elasticsearch geospatial aggregation use case?

**URL:** <https://discuss.elastic.co/t/does-elasticsearch-geospatial-aggregation-use-case/36127>\
**Category:** Elasticsearch\
**Created:** [December 2, 2015, 6:07am UTC](https://discuss.elastic.co/t/does-elasticsearch-geospatial-aggregation-use-case/36127 "2015-12-02T06:07:38Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![saipa](https://avatars.discourse-cdn.com/v4/letter/s/c5a1d2/32.png) [@saipa](https://discuss.elastic.co/u/saipa)\
**Post date:** [December 2, 2015, 6:07am UTC](https://discuss.elastic.co/t/does-elasticsearch-geospatial-aggregation-use-case/36127/1 "2015-12-02T06:07:39Z")

</div>

I have a question about if elasticsearch use cases. I have two files. One contains the boundaries of each state in the US. Another file contains the boundaries of north, south, east, and west regions of the US. Each boundary has a unique identiifer (either by state, or by region). If my document has only a latitude longitude field geospatially indexed (it does not contain a state field or a "region" field), is elasticsearch able to output aggregations based on "state" or "region" based on the boundaries I pass/tell elasticsearch about? Or is this not supported and I have to put "state" and "region" fields into each document I index to be able to aggregate?

---

<div class="post-metadata">

**Author:** ![colings86](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/colings86/32/44960_2.png) [@colings86](https://discuss.elastic.co/u/colings86)\
**Post date:** [December 2, 2015, 8:56am UTC](https://discuss.elastic.co/t/does-elasticsearch-geospatial-aggregation-use-case/36127/2 "2015-12-02T08:56:39Z")

</div>

You could achieve this by using the [`filters` aggregation](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations-bucket-filters-aggregation.html) and defining a [`geo_polygon`](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-geo-polygon-query.html) query for each state/region within this aggregation to group your results by each state/region.

Hope that helps

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [July 5, 2017, 11:34pm UTC](https://discuss.elastic.co/t/does-elasticsearch-geospatial-aggregation-use-case/36127/3 "2017-07-05T23:34:14Z")

</div>


