# Internal geo distance calculation in Elastic Search

**URL:** <https://discuss.elastic.co/t/internal-geo-distance-calculation-in-elastic-search/15889>\
**Category:** Elasticsearch\
**Created:** [February 19, 2014, 9:13am UTC](https://discuss.elastic.co/t/internal-geo-distance-calculation-in-elastic-search/15889 "2014-02-19T09:13:14Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![golchhamohit](https://avatars.discourse-cdn.com/v4/letter/g/e19adc/32.png) [@golchhamohit](https://discuss.elastic.co/u/golchhamohit)\
**Post date:** [February 19, 2014, 9:13am UTC](https://discuss.elastic.co/t/internal-geo-distance-calculation-in-elastic-search/15889/1 "2014-02-19T09:13:14Z")

</div>

Hi all,

```
       I am new to this group and new to Elastic Search as well. I had 

```

been using geo location facilities of Elastic Search and I wondered how  
internally does the Elastic Search calculates distances between two points  
on earth. I heard about great circle distance which calculates distances  
like a crow fly ignoring the roads and other aspects. Does Elastic Search  
uses same kind of technique or does it have a separate technique. ?

Thanks & Regards,  
Mohit Golchha

--  
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/6c066a00-2c99-48d5-81fd-b74bf38a1af0%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/6c066a00-2c99-48d5-81fd-b74bf38a1af0%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![Binh\_Ly](https://avatars.discourse-cdn.com/v4/letter/b/ce7236/32.png) [@Binh\_Ly](https://discuss.elastic.co/u/Binh_Ly)\
**Post date:** [February 19, 2014, 2:54pm UTC](https://discuss.elastic.co/t/internal-geo-distance-calculation-in-elastic-search/15889/2 "2014-02-19T14:54:20Z")

</div>

If you go here:

[http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-geo-distance-filter.html](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-geo-distance-filter.html)

You can see the distance\_type parameter which specifies the different types  
of calculations you can do with this filter.

--  
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/b97560d2-f90d-459c-8e09-47db6c6fb1e1%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/b97560d2-f90d-459c-8e09-47db6c6fb1e1%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![hari](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hari/32/1582_2.png) [@hari](https://discuss.elastic.co/u/hari)\
**Post date:** [February 19, 2014, 3:03pm UTC](https://discuss.elastic.co/t/internal-geo-distance-calculation-in-elastic-search/15889/3 "2014-02-19T15:03:59Z")

</div>

I have a related question, I know that it supports arc (better precision),  
sloppy\_arc(faster but less precise) or plane (fastest)  
which one of these distance types is better if I want to show the results  
to the user considering driving distance between two points?

On Wednesday, February 19, 2014 8:54:20 AM UTC-6, Binh Ly wrote:

> If you go here:
> 
> [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/query-dsl-geo-distance-filter.html)
> 
> You can see the distance\_type parameter which specifies the different  
> types of calculations you can do with this filter.

--  
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/272cb00c-24f6-49ab-8cb1-87e25bc6518c%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/272cb00c-24f6-49ab-8cb1-87e25bc6518c%40googlegroups.com).  
For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

---

<div class="post-metadata">

**Author:** ![jpountz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jpountz/32/45836_2.png) [@jpountz](https://discuss.elastic.co/u/jpountz)\
**Post date:** [February 19, 2014, 4:12pm UTC](https://discuss.elastic.co/t/internal-geo-distance-calculation-in-elastic-search/15889/4 "2014-02-19T16:12:11Z")

</div>

arc and sloppy\_arc use the haversine formula while plane computes distances  
as if the earth was a plane.

Although plane is the fastest option, it only has good accuracy if you are  
not too far from the equator and if your points are close to each other.

The difference between arc and sloppy\_arc is that sloppy\_arc uses  
implementations of cosinus and arcsinus that trade accuracy for speed  
(based on tables of values and taylor series). In my opinion, you would  
almost always want to use sloppy\_arc as it is significantly faster than arc  
while the error is small enough to not be an issue for user experience.  
Actually, the main reason why we didn't remove the arc distance computation  
implementation is to be able to make sure, in case of weird distances, that  
the error is not due to the sloppyness of the distance computation function.

Please note that even arc has accuracy issues because it assumes that the  
earth is round (although it is an ellipsoid) but the future release of  
Lucene is going to take this better into account so this will benefit  
Elasticsearch as well ([[LUCENE-5271] A slightly more accurate SloppyMath distance - ASF JIRA](https://issues.apache.org/jira/browse/LUCENE-5271)).

On Wed, Feb 19, 2014 at 4:03 PM, Hariharan Vadivelu [hariinfo@gmail.com](mailto:hariinfo@gmail.com)wrote:

> I have a related question, I know that it supports arc (better  
> precision), sloppy\_arc(faster but less precise) or plane (fastest)  
> which one of these distance types is better if I want to show the results  
> to the user considering driving distance between two points?
> 
> On Wednesday, February 19, 2014 8:54:20 AM UTC-6, Binh Ly wrote:
> 
> > If you go here:
> > 
> > [Elasticsearch Platform — Find real-time answers at scale | Elastic](http://www.elasticsearch.org/guide/en/elasticsearch/)  
> > reference/current/query-dsl-geo-distance-filter.html
> > 
> > You can see the distance\_type parameter which specifies the different  
> > types of calculations you can do with this filter.
> 
> --  
> 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/272cb00c-24f6-49ab-8cb1-87e25bc6518c%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/272cb00c-24f6-49ab-8cb1-87e25bc6518c%40googlegroups.com)  
> .
> 
> For more options, visit [https://groups.google.com/groups/opt\_out](https://groups.google.com/groups/opt_out).

--  
Adrien Grand

--  
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/CAL6Z4j4B%3DO7wt94ivDBV4p\_Z16XjgrHPRw2d9fDU5UKDxa8B2g%40mail.gmail.com](https://groups.google.com/d/msgid/elasticsearch/CAL6Z4j4B%3DO7wt94ivDBV4p_Z16XjgrHPRw2d9fDU5UKDxa8B2g%40mail.gmail.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, 1:49am UTC](https://discuss.elastic.co/t/internal-geo-distance-calculation-in-elastic-search/15889/5 "2017-07-06T01:49:00Z")

</div>


