# Geohash\_cell filter

**URL:** <https://discuss.elastic.co/t/geohash-cell-filter/12723>\
**Category:** Elasticsearch\
**Created:** [July 9, 2013, 3:48pm UTC](https://discuss.elastic.co/t/geohash-cell-filter/12723 "2013-07-09T15:48:34Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![Andrej](https://avatars.discourse-cdn.com/v4/letter/a/d9b06d/32.png) [@Andrej](https://discuss.elastic.co/u/Andrej)\
**Post date:** [July 9, 2013, 3:48pm UTC](https://discuss.elastic.co/t/geohash-cell-filter/12723/1 "2013-07-09T15:48:34Z")

</div>

Hi,

I tried to use geohash\_cell filter, as its an interesting functionality. My  
mapping for the geopoint looks like:

LOCATION: {  
lat\_lon: true  
geohash\_prefix: true  
type: geo\_point  
geohash: true  
}

Testing with the example query from the docs site works for me:  
{  
"query": {  
"filtered": {  
"query": {  
"match\_all": {}  
},  
"filter": {  
"geohash\_cell": {  
"LOCATION": {  
"lat": 13.408,  
"lon": 52.5186  
},  
"precision": 3,  
"neighbors": true  
}  
}  
}  
}  
}

So I think mapping and indexing is right. Then I wanted to filter not by  
point and precision but directly by geohash (as found in the issue 3218),  
but this aint working

{  
"query": {  
"filtered": {  
"query": {  
"match\_all": {}  
},  
"filter": {  
"geohash\_cell": {  
"field": "LOCATION",  
"geohash": "u30"  
}  
}  
}  
}  
}

Can someone point me to what I am doing wrong or how to filter directly by  
geohash?

Thanks,  
Andrej

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![chilling](https://avatars.discourse-cdn.com/v4/letter/c/b3f665/32.png) [@chilling](https://discuss.elastic.co/u/chilling)\
**Post date:** [July 10, 2013, 7:51am UTC](https://discuss.elastic.co/t/geohash-cell-filter/12723/2 "2013-07-10T07:51:18Z")

</div>

Hi Andrej,

so far your setup look good, Do you have any clue of what's not working?  
Which version are you using? Do you get any error messages?

cheers,  
Florian

On Tuesday, July 9, 2013 5:48:34 PM UTC+2, Andrej Rosenheinrich wrote:

> Hi,
> 
> I tried to use geohash\_cell filter, as its an interesting functionality.  
> My mapping for the geopoint looks like:
> 
> LOCATION: {  
> lat\_lon: true  
> geohash\_prefix: true  
> type: geo\_point  
> geohash: true  
> }
> 
> Testing with the example query from the docs site works for me:  
> {  
> "query": {  
> "filtered": {  
> "query": {  
> "match\_all": {}  
> },  
> "filter": {  
> "geohash\_cell": {  
> "LOCATION": {  
> "lat": 13.408,  
> "lon": 52.5186  
> },  
> "precision": 3,  
> "neighbors": true  
> }  
> }  
> }  
> }  
> }
> 
> So I think mapping and indexing is right. Then I wanted to filter not by  
> point and precision but directly by geohash (as found in the issue 3218),  
> but this aint working
> 
> {  
> "query": {  
> "filtered": {  
> "query": {  
> "match\_all": {}  
> },  
> "filter": {  
> "geohash\_cell": {  
> "field": "LOCATION",  
> "geohash": "u30"  
> }  
> }  
> }  
> }  
> }
> 
> Can someone point me to what I am doing wrong or how to filter directly by  
> geohash?
> 
> Thanks,  
> Andrej

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![chilling](https://avatars.discourse-cdn.com/v4/letter/c/b3f665/32.png) [@chilling](https://discuss.elastic.co/u/chilling)\
**Post date:** [July 10, 2013, 8:21am UTC](https://discuss.elastic.co/t/geohash-cell-filter/12723/3 "2013-07-10T08:21:05Z")

</div>

Hi Andrej,

I just recognized the mistake. try:

{  
"query": {  
"filtered": {  
"query": {  
"match\_all": {}  
},  
"filter": {  
"geohash\_cell": {  
"LOCATION": "u30"  
}  
}  
}  
}  
}

cheers,  
Florian

On Wednesday, July 10, 2013 9:51:18 AM UTC+2, Florian Schilling wrote:

> Hi Andrej,
> 
> so far your setup look good, Do you have any clue of what's not working?  
> Which version are you using? Do you get any error messages?
> 
> cheers,  
> Florian
> 
> On Tuesday, July 9, 2013 5:48:34 PM UTC+2, Andrej Rosenheinrich wrote:
> 
> > Hi,
> > 
> > I tried to use geohash\_cell filter, as its an interesting functionality.  
> > My mapping for the geopoint looks like:
> > 
> > LOCATION: {  
> > lat\_lon: true  
> > geohash\_prefix: true  
> > type: geo\_point  
> > geohash: true  
> > }
> > 
> > Testing with the example query from the docs site works for me:  
> > {  
> > "query": {  
> > "filtered": {  
> > "query": {  
> > "match\_all": {}  
> > },  
> > "filter": {  
> > "geohash\_cell": {  
> > "LOCATION": {  
> > "lat": 13.408,  
> > "lon": 52.5186  
> > },  
> > "precision": 3,  
> > "neighbors": true  
> > }  
> > }  
> > }  
> > }  
> > }
> > 
> > So I think mapping and indexing is right. Then I wanted to filter not by  
> > point and precision but directly by geohash (as found in the issue 3218),  
> > but this aint working
> > 
> > {  
> > "query": {  
> > "filtered": {  
> > "query": {  
> > "match\_all": {}  
> > },  
> > "filter": {  
> > "geohash\_cell": {  
> > "field": "LOCATION",  
> > "geohash": "u30"  
> > }  
> > }  
> > }  
> > }  
> > }
> > 
> > Can someone point me to what I am doing wrong or how to filter directly  
> > by geohash?
> > 
> > Thanks,  
> > Andrej

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Andrej](https://avatars.discourse-cdn.com/v4/letter/a/d9b06d/32.png) [@Andrej](https://discuss.elastic.co/u/Andrej)\
**Post date:** [July 10, 2013, 9:48am UTC](https://discuss.elastic.co/t/geohash-cell-filter/12723/4 "2013-07-10T09:48:01Z")

</div>

Hi Florian,

thanks a lot, that works! May be it would be helpful to add this version of  
the filter to the geohash\_cell filter docu?

Cheers,  
Andrej

Am Mittwoch, 10. Juli 2013 10:21:05 UTC+2 schrieb Florian Schilling:

> Hi Andrej,
> 
> I just recognized the mistake. try:
> 
> {  
> "query": {  
> "filtered": {  
> "query": {  
> "match\_all": {}  
> },  
> "filter": {  
> "geohash\_cell": {  
> "LOCATION": "u30"  
> }  
> }  
> }  
> }  
> }
> 
> cheers,  
> Florian
> 
> On Wednesday, July 10, 2013 9:51:18 AM UTC+2, Florian Schilling wrote:
> 
> > Hi Andrej,
> > 
> > so far your setup look good, Do you have any clue of what's not working?  
> > Which version are you using? Do you get any error messages?
> > 
> > cheers,  
> > Florian
> > 
> > On Tuesday, July 9, 2013 5:48:34 PM UTC+2, Andrej Rosenheinrich wrote:
> > 
> > > Hi,
> > > 
> > > I tried to use geohash\_cell filter, as its an interesting functionality.  
> > > My mapping for the geopoint looks like:
> > > 
> > > LOCATION: {  
> > > lat\_lon: true  
> > > geohash\_prefix: true  
> > > type: geo\_point  
> > > geohash: true  
> > > }
> > > 
> > > Testing with the example query from the docs site works for me:  
> > > {  
> > > "query": {  
> > > "filtered": {  
> > > "query": {  
> > > "match\_all": {}  
> > > },  
> > > "filter": {  
> > > "geohash\_cell": {  
> > > "LOCATION": {  
> > > "lat": 13.408,  
> > > "lon": 52.5186  
> > > },  
> > > "precision": 3,  
> > > "neighbors": true  
> > > }  
> > > }  
> > > }  
> > > }  
> > > }
> > > 
> > > So I think mapping and indexing is right. Then I wanted to filter not by  
> > > point and precision but directly by geohash (as found in the issue 3218),  
> > > but this aint working
> > > 
> > > {  
> > > "query": {  
> > > "filtered": {  
> > > "query": {  
> > > "match\_all": {}  
> > > },  
> > > "filter": {  
> > > "geohash\_cell": {  
> > > "field": "LOCATION",  
> > > "geohash": "u30"  
> > > }  
> > > }  
> > > }  
> > > }  
> > > }
> > > 
> > > Can someone point me to what I am doing wrong or how to filter directly  
> > > by geohash?
> > > 
> > > Thanks,  
> > > Andrej

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![chilling](https://avatars.discourse-cdn.com/v4/letter/c/b3f665/32.png) [@chilling](https://discuss.elastic.co/u/chilling)\
**Post date:** [July 11, 2013, 8:09am UTC](https://discuss.elastic.co/t/geohash-cell-filter/12723/5 "2013-07-11T08:09:50Z")

</div>

Hi Andrej,

you're right. The format has been updated recently to match the other  
filter formats.  
See [Geohash filter format · Issue #3229 · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/issues/3229). This format  
is described  
on [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/query-dsl/geohash-cell-filter/).

cheers,  
Florian

On Wednesday, July 10, 2013 11:48:01 AM UTC+2, Andrej Rosenheinrich wrote:

> Hi Florian,
> 
> thanks a lot, that works! May be it would be helpful to add this version  
> of the filter to the geohash\_cell filter docu?
> 
> Cheers,  
> Andrej
> 
> Am Mittwoch, 10. Juli 2013 10:21:05 UTC+2 schrieb Florian Schilling:
> 
> > Hi Andrej,
> > 
> > I just recognized the mistake. try:
> > 
> > {  
> > "query": {  
> > "filtered": {  
> > "query": {  
> > "match\_all": {}  
> > },  
> > "filter": {  
> > "geohash\_cell": {  
> > "LOCATION": "u30"  
> > }  
> > }  
> > }  
> > }  
> > }
> > 
> > cheers,  
> > Florian
> > 
> > On Wednesday, July 10, 2013 9:51:18 AM UTC+2, Florian Schilling wrote:
> > 
> > > Hi Andrej,
> > > 
> > > so far your setup look good, Do you have any clue of what's not working?  
> > > Which version are you using? Do you get any error messages?
> > > 
> > > cheers,  
> > > Florian
> > > 
> > > On Tuesday, July 9, 2013 5:48:34 PM UTC+2, Andrej Rosenheinrich wrote:
> > > 
> > > > Hi,
> > > > 
> > > > I tried to use geohash\_cell filter, as its an interesting  
> > > > functionality. My mapping for the geopoint looks like:
> > > > 
> > > > LOCATION: {  
> > > > lat\_lon: true  
> > > > geohash\_prefix: true  
> > > > type: geo\_point  
> > > > geohash: true  
> > > > }
> > > > 
> > > > Testing with the example query from the docs site works for me:  
> > > > {  
> > > > "query": {  
> > > > "filtered": {  
> > > > "query": {  
> > > > "match\_all": {}  
> > > > },  
> > > > "filter": {  
> > > > "geohash\_cell": {  
> > > > "LOCATION": {  
> > > > "lat": 13.408,  
> > > > "lon": 52.5186  
> > > > },  
> > > > "precision": 3,  
> > > > "neighbors": true  
> > > > }  
> > > > }  
> > > > }  
> > > > }  
> > > > }
> > > > 
> > > > So I think mapping and indexing is right. Then I wanted to filter not  
> > > > by point and precision but directly by geohash (as found in the issue  
> > > > 3218), but this aint working
> > > > 
> > > > {  
> > > > "query": {  
> > > > "filtered": {  
> > > > "query": {  
> > > > "match\_all": {}  
> > > > },  
> > > > "filter": {  
> > > > "geohash\_cell": {  
> > > > "field": "LOCATION",  
> > > > "geohash": "u30"  
> > > > }  
> > > > }  
> > > > }  
> > > > }  
> > > > }
> > > > 
> > > > Can someone point me to what I am doing wrong or how to filter directly  
> > > > by geohash?
> > > > 
> > > > Thanks,  
> > > > Andrej

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Andrej](https://avatars.discourse-cdn.com/v4/letter/a/d9b06d/32.png) [@Andrej](https://discuss.elastic.co/u/Andrej)\
**Post date:** [July 11, 2013, 8:45am UTC](https://discuss.elastic.co/t/geohash-cell-filter/12723/6 "2013-07-11T08:45:39Z")

</div>

Florian,

may I ask if bounding box filter is benefitting from indexed geohashes?  
Looking over the code (havent understood it completely, honestly) it doesnt  
seem so? Would it make sense to try to emulate bounding box as a boolfilter  
of geohash\_cell filter? Or would you consider bounding box implementation  
as reasonable fast?

What I actually want to do is to get the best results within an area. So my  
idea is running a match\_all query and a bounding box filter to select  
documents within that area (assuming that bounding box is fast) and rescore  
with the query that calculates scores and returns the best results. Would  
you think this approach makes sense?

Thanks for your help!  
Andrej

PS: Will you attend ElasticSearch User Group Meeting in Berlin this month?  
May be we could discuss this face to face 😉

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![chilling](https://avatars.discourse-cdn.com/v4/letter/c/b3f665/32.png) [@chilling](https://discuss.elastic.co/u/chilling)\
**Post date:** [July 12, 2013, 3:07pm UTC](https://discuss.elastic.co/t/geohash-cell-filter/12723/7 "2013-07-12T15:07:19Z")

</div>

Hey Andrej,

the boundingbox filter and the geohash\_cell filter are two completely  
different filters. Filter by boundingboxes is the more intuitive approach,  
since you are able to define your own ranges and positions. The  
geohash\_cell filter in turn, works on a pre-defined grid with fixed sizes  
of boxes.  
So filtering boundingboxes is similar to (at least) two range filter. One  
for latitude and one for the longitude. The last one can be extended to a  
third one if the filter crosses the dateline. Geohash filters work in a  
different way: Since all prefixes of the geohash related to a document are  
stored this filter is similar to singe term lookup (or a terms look if  
neighbors is enabled). This makes the geohash\_cell filters very fast with  
the limitation to the fixed grid.  
I think in your case the boundingbox filter will work fine. Another case I  
could think of is a geo\_distance filter. This one is not very fast. So the  
geohash filter can be used as a pre-filter which roughly selects all  
documents within your area and then apply the geo\_distance filter to this  
reduced resultset. This can be done in a single call. Also this filter  
might be interesting for faceting...  
I think there are a lot of applications for this and I'll try to join the  
usergroup at the end of the month.

Cheers,  
Florian

On Thursday, July 11, 2013 10:45:39 AM UTC+2, Andrej Rosenheinrich wrote:

> Florian,
> 
> may I ask if bounding box filter is benefitting from indexed geohashes?  
> Looking over the code (havent understood it completely, honestly) it doesnt  
> seem so? Would it make sense to try to emulate bounding box as a boolfilter  
> of geohash\_cell filter? Or would you consider bounding box implementation  
> as reasonable fast?
> 
> What I actually want to do is to get the best results within an area. So  
> my idea is running a match\_all query and a bounding box filter to select  
> documents within that area (assuming that bounding box is fast) and rescore  
> with the query that calculates scores and returns the best results. Would  
> you think this approach makes sense?
> 
> Thanks for your help!  
> Andrej
> 
> PS: Will you attend Elasticsearch User Group Meeting in Berlin this month?  
> May be we could discuss this face to face 😉

--  
You received this message because you are subscribed to the Google Groups "elasticsearch" group.  
To unsubscribe from this group and stop receiving emails from it, send an email to [elasticsearch+unsubscribe@googlegroups.com](mailto:elasticsearch+unsubscribe@googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<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:26am UTC](https://discuss.elastic.co/t/geohash-cell-filter/12723/8 "2017-07-06T02:26:45Z")

</div>


