# Geo distance and bounding box

**URL:** https://discuss.elastic.co/t/geo-distance-and-bounding-box/10656
**Category:** Elasticsearch
**Created:** [February 7, 2013, 8:36pm UTC](https://discuss.elastic.co/t/geo-distance-and-bounding-box/10656 "2013-02-07T20:36:46Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![amnesia7](https://avatars.discourse-cdn.com/v4/letter/a/58f4c7/32.png) [@amnesia7](https://discuss.elastic.co/u/amnesia7)
#### Post date: [February 7, 2013, 8:36pm UTC](https://discuss.elastic.co/t/geo-distance-and-bounding-box/10656/1 "2013-02-07T20:36:46Z")

</div>

I am doing a geo\_distance filter in my search (and I also have geo\_distance  
as one of my sorting fields).

I'm not sure how ES performs the geo\_distance filtering under the hood but  
I was wondering whether I should consider applying a bounding box  
(geo\_bbox) filter as well to my search to limit the number of records that  
the geo\_distance filter then needs to check individual distances for.

This way ES would be only be checking the distance of records that were  
within the bounding box rather than all records that matched the search  
term.

How does that sound?

--  
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: ![Clinton\_Gormley](https://avatars.discourse-cdn.com/v4/letter/c/50afbb/32.png) [@Clinton\_Gormley](https://discuss.elastic.co/u/Clinton_Gormley)
#### Post date: [February 8, 2013, 10:02am UTC](https://discuss.elastic.co/t/geo-distance-and-bounding-box/10656/2 "2013-02-08T10:02:48Z")

</div>

> I'm not sure how ES performs the geo\_distance filtering under the hood  
> but I was wondering whether I should consider applying a bounding box  
> (geo\_bbox) filter as well to my search to limit the number of records  
> that the geo\_distance filter then needs to check individual distances  
> for.

Have a look at the optimize\_bbox parameter on the geo-distance filter  
page:

> **[Elasticsearch Platform — Find real-time answers at scale](https://www.elastic.co)**
>
> Power insights and outcomes with the Elasticsearch Platform and AI. See into your data and find answers that matter with enterprise solutions designed to help you build, observe, and protect. Try Elasticsearch free today.

clint

--  
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: [February 8, 2013, 10:22am UTC](https://discuss.elastic.co/t/geo-distance-and-bounding-box/10656/3 "2013-02-08T10:22:35Z")

</div>

Hi Clint,

thanks for pointing out to this option, looks like I've overseen it in the  
past. I am not sure what the possible values (memory, indexed, ?) mean in  
detail, can you share a line on this here? In the meantime I will throw  
away my manual bounding box preprocessing ... 😉

Thanks!  
Andrej

Am Freitag, 8. Februar 2013 11:02:48 UTC+1 schrieb Clinton Gormley:

> > I'm not sure how ES performs the geo\_distance filtering under the hood  
> > but I was wondering whether I should consider applying a bounding box  
> > (geo\_bbox) filter as well to my search to limit the number of records  
> > that the geo\_distance filter then needs to check individual distances  
> > for.
> 
> Have a look at the optimize\_bbox parameter on the geo-distance filter  
> page:
> 
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/reference/query-dsl/geo-distance-filter.html)
> 
> clint

--  
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: ![Clinton\_Gormley](https://avatars.discourse-cdn.com/v4/letter/c/50afbb/32.png) [@Clinton\_Gormley](https://discuss.elastic.co/u/Clinton_Gormley)
#### Post date: [February 8, 2013, 10:32am UTC](https://discuss.elastic.co/t/geo-distance-and-bounding-box/10656/4 "2013-02-08T10:32:07Z")

</div>

On Fri, 2013-02-08 at 02:22 -0800, Andrej Rosenheinrich wrote:

> Hi Clint,
> 
> thanks for pointing out to this option, looks like I've overseen it in  
> the past. I am not sure what the possible values (memory, indexed, ?)  
> mean in detail, can you share a line on this here? In the meantime I  
> will throw away my manual bounding box preprocessing ... 😉

'memory' the default, just runs a geo\_bbox check on each geo-point  
loaded in memory.

'indexed' can only apply if you also set the lat/lon values to be  
indexed separately (set lat\_lon to true in your geo-point mapping)

> **[Elasticsearch Platform — Find real-time answers at scale](https://www.elastic.co)**
>
> Power insights and outcomes with the Elasticsearch Platform and AI. See into your data and find answers that matter with enterprise solutions designed to help you build, observe, and protect. Try Elasticsearch free today.

that way it can use a range filter to do the bbox check, which is  
faster. (note that this option will only work for single geopoint values

- it won't work if you have multiple geopoints per field)

clint

> Thanks!  
> Andrej
> 
> Am Freitag, 8. Februar 2013 11:02:48 UTC+1 schrieb Clinton Gormley:
> 
> ```
> > I'm not sure how ES performs the geo_distance filtering
> under the hood 
> > but I was wondering whether I should consider applying a
> bounding box 
> > (geo_bbox) filter as well to my search to limit the number
> of records 
> > that the geo_distance filter then needs to check individual
> distances 
> > for. 
>     
> Have a look at the optimize_bbox parameter on the geo-distance
> filter 
> page: 
> http://www.elasticsearch.org/guide/reference/query-dsl/geo-distance-filter.html 
>     
> clint 
> 
> ```
> 
> --  
> 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).

--  
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: ![amnesia7](https://avatars.discourse-cdn.com/v4/letter/a/58f4c7/32.png) [@amnesia7](https://discuss.elastic.co/u/amnesia7)
#### Post date: [February 9, 2013, 12:06pm UTC](https://discuss.elastic.co/t/geo-distance-and-bounding-box/10656/5 "2013-02-09T12:06:13Z")

</div>

Thanks for pointing that out Clint.

--  
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:52am UTC](https://discuss.elastic.co/t/geo-distance-and-bounding-box/10656/6 "2017-07-06T02:52:18Z")

</div>


