# Sample geo region facet

**URL:** <https://discuss.elastic.co/t/sample-geo-region-facet/10193>\
**Category:** Elasticsearch\
**Created:** [December 28, 2012, 3:20pm UTC](https://discuss.elastic.co/t/sample-geo-region-facet/10193 "2012-12-28T15:20:23Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [December 28, 2012, 3:20pm UTC](https://discuss.elastic.co/t/sample-geo-region-facet/10193/1 "2012-12-28T15:20:23Z")

</div>

Hi,

holidays, at your parents for too long, split from your better half...  
inevitably leads to code 🙂

So I hacked up [https://github.com/spinscale/elasticsearch-facet-georegion](https://github.com/spinscale/elasticsearch-facet-georegion)

It is a small sample facet, which everyone is encouraged to use for his own  
projects. The georegion facet groups results, which have a geo location  
stored in the document, by arbitrary region. My sample includes a document  
for many countries in the world, but you could change that to reflect only  
the states in germany or just the continents by changing the configuration  
to a different file, which includes the data you need (in GeoJSON format if  
I am not mistaken).

When indexing a few towns like Paris, Munich, Berlin and Cologne with its  
correct location (as a geo\_point type), the facet will return "Germany:3"  
and "France:1"...

It is slow as hell, so performance improvements or better integration in  
the not too well documented geo features of elasticsearch would be great as  
minor tips 🙂 (however I do not intend to develop it any further)

Have fun, and reuse whatever you want from the code.

--Alexander

--

---

<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 6, 2017, 2:58am UTC](https://discuss.elastic.co/t/sample-geo-region-facet/10193/2 "2017-07-06T02:58:17Z")

</div>


