# Internal implementation details when using geo hash

**URL:** https://discuss.elastic.co/t/internal-implementation-details-when-using-geo-hash/20755
**Category:** Elasticsearch
**Created:** [November 14, 2014, 4:29pm UTC](https://discuss.elastic.co/t/internal-implementation-details-when-using-geo-hash/20755 "2014-11-14T16:29:54Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Todd\_Nine](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/todd_nine/32/778_2.png) [@Todd\_Nine](https://discuss.elastic.co/u/Todd_Nine)
#### Post date: [November 14, 2014, 4:29pm UTC](https://discuss.elastic.co/t/internal-implementation-details-when-using-geo-hash/20755/1 "2014-11-14T16:29:54Z")

</div>

Hey All,  
I have a question about the internal implementation of geo hashes and  
distance filters. Here is my current understanding, I'm struggling to  
figure out how to apply these to our queries internally in ES.

Using bool queries are very efficient. Internally they  
perform bitmap union, intersection, and subtraction for very fast candidate  
aggregation per term.

Geo distance filters are then run on the results of the candidates from the  
bitmap logic. Each document must be evaluated individually in memory.  
Obviously for large documents sets from the bitmap evaluation, this is  
inefficient.

What happens when someone only gives our application a geo distance query?  
To make this more efficient, I would like to use geo hashing. ES seems to  
have geo hashing built in, but it's documented as filter. For instance, I  
envision the following workflow internally in ES.

1. User searches for all matches within 2k of their current location
2. Use a geohash to create a hash that will encapsulate all points within  
2k of their current location
3. Use the bool query with this geo hash to narrow the candidate result set
4. Apply the distance filter to these candidates to get more accurate  
results.

However, when reading the documentation on searching geo hashing, it's  
still a filter. Internally, does it use geohasing and the fast bitmaps  
since it's a string match, then filter, or is it all filters and the hash  
is evaluated in memory for all documents?

[http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.4/query-dsl-geohash-cell-filter.html](http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.4/query-dsl-geohash-cell-filter.html)

Thanks,  
Todd

--  
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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/5ee6fb94-e0a2-4e39-8537-23c8c8f74fe0%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/5ee6fb94-e0a2-4e39-8537-23c8c8f74fe0%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

### Author: ![Rod\_Simpson](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rod_simpson/32/1093_2.png) [@Rod\_Simpson](https://discuss.elastic.co/u/Rod_Simpson)
#### Post date: [November 19, 2014, 7:15pm UTC](https://discuss.elastic.co/t/internal-implementation-details-when-using-geo-hash/20755/2 "2014-11-19T19:15:03Z")

</div>

+1 any insights here would be most appreciated.

On Friday, November 14, 2014 9:29:54 AM UTC-7, Todd Nine wrote:

> Hey All,  
> I have a question about the internal implementation of geo hashes and  
> distance filters. Here is my current understanding, I'm struggling to  
> figure out how to apply these to our queries internally in ES.
> 
> Using bool queries are very efficient. Internally they  
> perform bitmap union, intersection, and subtraction for very fast candidate  
> aggregation per term.
> 
> Geo distance filters are then run on the results of the candidates from  
> the bitmap logic. Each document must be evaluated individually in memory.  
> Obviously for large documents sets from the bitmap evaluation, this is  
> inefficient.
> 
> What happens when someone only gives our application a geo distance query?  
> To make this more efficient, I would like to use geo hashing. ES seems to  
> have geo hashing built in, but it's documented as filter. For instance, I  
> envision the following workflow internally in ES.
> 
> 1. User searches for all matches within 2k of their current location
> 2. Use a geohash to create a hash that will encapsulate all points within  
> 2k of their current location
> 3. Use the bool query with this geo hash to narrow the candidate result set
> 4. Apply the distance filter to these candidates to get more accurate  
> results.
> 
> However, when reading the documentation on searching geo hashing, it's  
> still a filter. Internally, does it use geohasing and the fast bitmaps  
> since it's a string match, then filter, or is it all filters and the hash  
> is evaluated in memory for all documents?
> 
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.4/query-dsl-geohash-cell-filter.html)
> 
> Thanks,  
> Todd

--  
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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/3170d1e3-47d4-422e-973e-d003b1380068%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/3170d1e3-47d4-422e-973e-d003b1380068%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

### Author: ![Shawn\_Feldman](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/shawn_feldman/32/759_2.png) [@Shawn\_Feldman](https://discuss.elastic.co/u/Shawn_Feldman)
#### Post date: [November 19, 2014, 8:09pm UTC](https://discuss.elastic.co/t/internal-implementation-details-when-using-geo-hash/20755/3 "2014-11-19T20:09:55Z")

</div>

would also like to know...

On Friday, November 14, 2014 9:29:54 AM UTC-7, Todd Nine wrote:

> Hey All,  
> I have a question about the internal implementation of geo hashes and  
> distance filters. Here is my current understanding, I'm struggling to  
> figure out how to apply these to our queries internally in ES.
> 
> Using bool queries are very efficient. Internally they  
> perform bitmap union, intersection, and subtraction for very fast candidate  
> aggregation per term.
> 
> Geo distance filters are then run on the results of the candidates from  
> the bitmap logic. Each document must be evaluated individually in memory.  
> Obviously for large documents sets from the bitmap evaluation, this is  
> inefficient.
> 
> What happens when someone only gives our application a geo distance query?  
> To make this more efficient, I would like to use geo hashing. ES seems to  
> have geo hashing built in, but it's documented as filter. For instance, I  
> envision the following workflow internally in ES.
> 
> 1. User searches for all matches within 2k of their current location
> 2. Use a geohash to create a hash that will encapsulate all points within  
> 2k of their current location
> 3. Use the bool query with this geo hash to narrow the candidate result set
> 4. Apply the distance filter to these candidates to get more accurate  
> results.
> 
> However, when reading the documentation on searching geo hashing, it's  
> still a filter. Internally, does it use geohasing and the fast bitmaps  
> since it's a string match, then filter, or is it all filters and the hash  
> is evaluated in memory for all documents?
> 
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.4/query-dsl-geohash-cell-filter.html)
> 
> Thanks,  
> Todd

--  
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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/a380f53e-c1d7-41f8-9daa-9f74e2bb54b2%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/a380f53e-c1d7-41f8-9daa-9f74e2bb54b2%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

### Author: ![George\_Reyes](https://avatars.discourse-cdn.com/v4/letter/g/ed8c4c/32.png) [@George\_Reyes](https://discuss.elastic.co/u/George_Reyes)
#### Post date: [November 21, 2014, 3:34pm UTC](https://discuss.elastic.co/t/internal-implementation-details-when-using-geo-hash/20755/4 "2014-11-21T15:34:27Z")

</div>

+1  
Yeah, having geo hashing done internally would be awesome. Kinda confused  
since it does only seem to be documented as a filter so any answer would be  
helpful.

Thanks!

On Friday, November 14, 2014 8:29:54 AM UTC-8, Todd Nine wrote:

> Hey All,  
> I have a question about the internal implementation of geo hashes and  
> distance filters. Here is my current understanding, I'm struggling to  
> figure out how to apply these to our queries internally in ES.
> 
> Using bool queries are very efficient. Internally they  
> perform bitmap union, intersection, and subtraction for very fast candidate  
> aggregation per term.
> 
> Geo distance filters are then run on the results of the candidates from  
> the bitmap logic. Each document must be evaluated individually in memory.  
> Obviously for large documents sets from the bitmap evaluation, this is  
> inefficient.
> 
> What happens when someone only gives our application a geo distance query?  
> To make this more efficient, I would like to use geo hashing. ES seems to  
> have geo hashing built in, but it's documented as filter. For instance, I  
> envision the following workflow internally in ES.
> 
> 1. User searches for all matches within 2k of their current location
> 2. Use a geohash to create a hash that will encapsulate all points within  
> 2k of their current location
> 3. Use the bool query with this geo hash to narrow the candidate result set
> 4. Apply the distance filter to these candidates to get more accurate  
> results.
> 
> However, when reading the documentation on searching geo hashing, it's  
> still a filter. Internally, does it use geohasing and the fast bitmaps  
> since it's a string match, then filter, or is it all filters and the hash  
> is evaluated in memory for all documents?
> 
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/en/elasticsearch/reference/1.4/query-dsl-geohash-cell-filter.html)
> 
> Thanks,  
> Todd

--  
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).  
To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/abfc6621-3035-48d4-b7ec-09ec190f65f2%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/abfc6621-3035-48d4-b7ec-09ec190f65f2%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<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, 12:48am UTC](https://discuss.elastic.co/t/internal-implementation-details-when-using-geo-hash/20755/5 "2017-07-06T00:48:25Z")

</div>


