# Distance calculation using geo\_distance filter is at least 100 miles wrong

**URL:** <https://discuss.elastic.co/t/distance-calculation-using-geo-distance-filter-is-at-least-100-miles-wrong/11787>\
**Category:** Elasticsearch\
**Created:** [May 2, 2013, 7:31pm UTC](https://discuss.elastic.co/t/distance-calculation-using-geo-distance-filter-is-at-least-100-miles-wrong/11787 "2013-05-02T19:31:06Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Bruno\_Miranda](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/bruno_miranda/32/746_2.png) [@Bruno\_Miranda](https://discuss.elastic.co/u/Bruno_Miranda)\
**Post date:** [May 2, 2013, 7:31pm UTC](https://discuss.elastic.co/t/distance-calculation-using-geo-distance-filter-is-at-least-100-miles-wrong/11787/1 "2013-05-02T19:31:06Z")

</div>

Here are all the curl commands to reproduce the issue. I am using ES 0.20.6.

Delete and Create index with proper mappings

curl -X DELETE [http://localhost:9200/search](http://localhost:9200/search)

curl -X POST [http://localhost:9200/search](http://localhost:9200/search) -d '{  
"mappings": {  
"document": {  
"properties": {  
"name": {  
"type": "string"  
},  
"lat\_lon": {  
"type": "geo\_point"  
}  
}  
}  
}  
}'

Index document

curl -X POST "[http://localhost:9200/search/document/](http://localhost:9200/search/document/)" -d '{  
"name": "Kimberly",  
"lat\_lon": [  
29.76,  
-95.36  
]  
}'

Search with a geo\_distance filter and a radius of 100 miles.

curl -X GET '[http://localhost:9200/search/\_search?pretty](http://localhost:9200/search/_search?pretty)' -d '{  
"filter": {  
"geo\_distance": {  
"lat\_lon": [  
32.8,  
-96.61  
],  
"distance": "100mi"  
}  
}  
}'

Matched doc has a lat, lon of 29.76, -95.36 which is ~244 miles away from  
32.8, -96.61 ([http://goo.gl/maps/OTFYi](http://goo.gl/maps/OTFYi))

{  
"took": 0,  
"timed\_out": false,  
"\_shards": {  
"total": 1,  
"successful": 1,  
"failed": 0  
},  
"hits": {  
"total": 1,  
"max\_score": 1,  
"hits": [  
{  
"\_index": "search",  
"\_type": "document",  
"\_id": "GUW3qTQGTz-rBTNF4ORFQQ",  
"\_score": 1,  
"\_source": {  
"name": "Kimberly",  
"lat\_lon": [  
29.76,  
-95.36  
]  
}  
}  
]  
}  
}

I even tried reversing the lat,lon order as the docs are confusing, but  
that is not the issue, with the reversed order no documents are matched  
even with the radius set to 2000 miles, which confirms I have the proper  
lat,lon order set in the queries above.

I also submitted a issue to the elasticsearch project in  
github: [https://github.com/elasticsearch/elasticsearch/issues/2976](https://github.com/elasticsearch/elasticsearch/issues/2976)

--  
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:38am UTC](https://discuss.elastic.co/t/distance-calculation-using-geo-distance-filter-is-at-least-100-miles-wrong/11787/2 "2017-07-06T02:38:35Z")

</div>


