# Getting geodistance filter working!

**URL:** <https://discuss.elastic.co/t/getting-geodistance-filter-working/15653>\
**Category:** Elasticsearch\
**Created:** [February 7, 2014, 2:19am UTC](https://discuss.elastic.co/t/getting-geodistance-filter-working/15653 "2014-02-07T02:19:36Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Florent\_Arcambal](https://avatars.discourse-cdn.com/v4/letter/f/7c8e57/32.png) [@Florent\_Arcambal](https://discuss.elastic.co/u/Florent_Arcambal)\
**Post date:** [February 7, 2014, 2:19am UTC](https://discuss.elastic.co/t/getting-geodistance-filter-working/15653/1 "2014-02-07T02:19:36Z")

</div>

Hello everybody,

I'm new to elatsicasearch I 'm tryning to have geodistance filter working !

I try to follow differnet piece of advises of the following thread:  
[http://elasticsearch-users.115913.n3.nabble.com/Update-mapping-td3952162.html](http://elasticsearch-users.115913.n3.nabble.com/Update-mapping-td3952162.html)

But I still can't get it to work correctly

For my test Im' using the Chrome extesion called sense  
(that's why my syntax is slightly different than the one with curl)

Anyway... Below you will find my different test,  
from the creation of the index, the mapping, the insert, and the different  
unsuccesfull search with geodistance filtering i've tried...

I hope some one could help me

Thx by advance

DELETE try  
PUT /try  
GET /try/\_mapping  
PUT /try/pins/\_mapping  
{  
"pin": {  
"properties": {  
"location": {  
"type": "geo\_point",  
"lat\_lon": "true"  
},  
"text": {  
"type": "string"  
}  
}  
}  
}  
PUT /test/pins/1  
{  
"pin" : {  
"location" : {  
"lat" : 40.20,  
"lon" : -71.44  
},  
"text" : "a great hostel"  
}  
}  
PUT /test/pins/2  
{  
"pin" : {  
"location" : {  
"lat" : 40.12,  
"lon" : -71.34  
},  
"text" : "my favorite family restaurant"  
}  
}

GET \_search  
{  
"query": {  
"match\_all": {}  
}  
}

GET \_search  
{  
"query": {  
"match\_all": {}  
},  
"filter": {  
"geo\_distance": {  
"distance": "1200km",  
"pin.location": {  
"lat": 40.15,  
"lon": -71.40  
}  
}  
}  
}

GET \_search  
{  
"filtered": {  
"query": {  
"match\_all": {}  
},  
"filter": {  
"geo\_distance": {  
"distance": "2000km",  
"pin.location": {  
"lat": 40.15,  
"lon": -70.40  
}  
}  
}  
}  
}

GET \_search  
{  
"query": {  
"filtered": {  
"query": {  
"match\_all": {}  
},  
"filter": {  
"geo\_distance": {  
"distance": "2000km",  
"pin.location": {  
"lat": 40.15,  
"lon": -70.40  
}  
}  
}  
}  
}  
}

--  
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/e4a5330b-f4a2-4c4c-8ab5-84baa5dcca41%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/e4a5330b-f4a2-4c4c-8ab5-84baa5dcca41%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 7, 2014, 1:25pm UTC](https://discuss.elastic.co/t/getting-geodistance-filter-working/15653/2 "2014-02-07T13:25:42Z")

</div>

Florent,

You probably just want to be careful with your index names, type, mapping,  
and actual document. So if you do something like this, it should work:

1. PUT [http://localhost:9200/try](http://localhost:9200/try)

2. PUT [http://localhost:9200/try/pin/\_mapping](http://localhost:9200/try/pin/_mapping)  
{  
"pin": {  
"properties": {  
"location": {  
"type": "geo\_point",  
"lat\_lon": "true"  
},  
"text": {  
"type": "string"  
}  
}  
}  
}

3. POST [http://localhost:9200/try/pin/1](http://localhost:9200/try/pin/1)  
{  
"location" : {  
"lat" : 40.20,  
"lon" : -71.44  
},  
"text" : "a great hostel"  
}

4. GET [http://localhost:9200/try/\_search](http://localhost:9200/try/_search)  
{  
"query": {  
"match\_all": {}  
},  
"filter": {  
"geo\_distance": {  
"distance": "1200km",  
"location": {  
"lat": 40.15,  
"lon": -71.4  
}  
}  
}  
}

--  
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/78532d9c-ced0-4627-809e-670e95b00cb3%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/78532d9c-ced0-4627-809e-670e95b00cb3%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:** ![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:51am UTC](https://discuss.elastic.co/t/getting-geodistance-filter-working/15653/3 "2017-07-06T01:51:45Z")

</div>


