# Geo distance filter always returns 0 results

**URL:** <https://discuss.elastic.co/t/geo-distance-filter-always-returns-0-results/20323>\
**Category:** Elasticsearch\
**Created:** [October 19, 2014, 4:51pm UTC](https://discuss.elastic.co/t/geo-distance-filter-always-returns-0-results/20323 "2014-10-19T16:51:47Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Driton\_Alija](https://avatars.discourse-cdn.com/v4/letter/d/278dde/32.png) [@Driton\_Alija](https://discuss.elastic.co/u/Driton_Alija)\
**Post date:** [October 19, 2014, 4:51pm UTC](https://discuss.elastic.co/t/geo-distance-filter-always-returns-0-results/20323/1 "2014-10-19T16:51:47Z")

</div>

Hi all. I want to be able to search with geo distance in ES 1.3.4.  
I did geo mapping:  
POST /geo/  
{ "mappings":{  
"pin" : {  
"properties" : {  
"location" : {  
"type" : "geo\_point"  
}  
}  
}  
}  
}  
Added some data in this format:  
PUT /geo/location/1  
{  
"pin" : {  
"location" : {  
"lat" : 42.4398181,  
"lon" : 21.466074  
},  
"text" : "Geolocation distance search"  
}  
}  
Tried to search with geo\_distance filter:  
POST geo/location/\_search  
{  
"query": {"filtered": {  
"query": {  
"match\_all": {}},  
"filter": {  
"geo\_distance": {  
"distance": "500",  
"distance\_unit": "km",  
"pin.location": {  
"lat" : 42.1,  
"lon" : 21.1  
}  
}  
}  
}}  
}  
And always getting 0 results even that this distance is 48.32 km.  
I tried many options and ES always returns 0 results to me.  
( I used sense extension above)

--  
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/fa9dc0f4-be05-4756-9cfb-3486cdd9a178%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/fa9dc0f4-be05-4756-9cfb-3486cdd9a178%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [October 19, 2014, 6:06pm UTC](https://discuss.elastic.co/t/geo-distance-filter-always-returns-0-results/20323/2 "2014-10-19T18:06:58Z")

</div>

It sounds like you created a mapping for type pin but sent documents with location type.

I'd check the index creation command. Check the mapping for location.

--  
David 😉  
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

> Le 19 oct. 2014 à 18:51, Driton Alija [dritonalija4@gmail.com](mailto:dritonalija4@gmail.com) a écrit :
> 
> ## Hi all. I want to be able to search with geo distance in ES 1.3.4. I did geo mapping: POST /geo/ { "mappings":{ "pin" : { "properties" : { "location" : { "type" : "geo\_point" } } } } } Added some data in this format: PUT /geo/location/1 { "pin" : { "location" : { "lat" : 42.4398181, "lon" : 21.466074 }, "text" : "Geolocation distance search" } } Tried to search with geo\_distance filter: POST geo/location/\_search { "query": {"filtered": { "query": { "match\_all": {}}, "filter": { "geo\_distance": { "distance": "500", "distance\_unit": "km", "pin.location": { "lat" : 42.1, "lon" : 21.1 } } } }} } And always getting 0 results even that this distance is 48.32 km. I tried many options and ES always returns 0 results to me. ( I used sense extension above)
> 
> 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/fa9dc0f4-be05-4756-9cfb-3486cdd9a178%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/fa9dc0f4-be05-4756-9cfb-3486cdd9a178%40googlegroups.com).  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
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/704BAA6D-0204-4073-8491-EA867A151207%40pilato.fr](https://groups.google.com/d/msgid/elasticsearch/704BAA6D-0204-4073-8491-EA867A151207%40pilato.fr).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Driton\_Alija](https://avatars.discourse-cdn.com/v4/letter/d/278dde/32.png) [@Driton\_Alija](https://discuss.elastic.co/u/Driton_Alija)\
**Post date:** [October 19, 2014, 6:17pm UTC](https://discuss.elastic.co/t/geo-distance-filter-always-returns-0-results/20323/3 "2014-10-19T18:17:13Z")

</div>

Hi David.

Thank you for your reply and help.

No I did the mapping for location not for pin.

Here is the attachment from the mapping that I did.

I appreciate your help.

[https://lh5.googleusercontent.com/-KlNYMUCpIn8/VEP\_yPU18gI/AAAAAAAAAEM/R1dlp1lMD3Q/s1600/mapping\_geo.PNG](https://lh5.googleusercontent.com/-KlNYMUCpIn8/VEP_yPU18gI/AAAAAAAAAEM/R1dlp1lMD3Q/s1600/mapping_geo.PNG)

On Sunday, October 19, 2014 8:07:12 PM UTC+2, David Pilato wrote:

> It sounds like you created a mapping for type pin but sent documents with  
> location type.
> 
> I'd check the index creation command. Check the mapping for location.
> 
> --  
> David 😉  
> Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs
> 
> Le 19 oct. 2014 à 18:51, Driton Alija \<[driton...@gmail.com](mailto:driton...@gmail.com) \<javascript:\>\>  
> a écrit :
> 
> Hi all. I want to be able to search with geo distance in ES 1.3.4.  
> I did geo mapping:  
> POST /geo/  
> { "mappings":{  
> "pin" : {  
> "properties" : {  
> "location" : {  
> "type" : "geo\_point"  
> }  
> }  
> }  
> }  
> }  
> Added some data in this format:  
> PUT /geo/location/1  
> {  
> "pin" : {  
> "location" : {  
> "lat" : 42.4398181,  
> "lon" : 21.466074  
> },  
> "text" : "Geolocation distance search"  
> }  
> }  
> Tried to search with geo\_distance filter:  
> POST geo/location/\_search  
> {  
> "query": {"filtered": {  
> "query": {  
> "match\_all": {}},  
> "filter": {  
> "geo\_distance": {  
> "distance": "500",  
> "distance\_unit": "km",  
> "pin.location": {  
> "lat" : 42.1,  
> "lon" : 21.1  
> }  
> }  
> }  
> }}  
> }  
> And always getting 0 results even that this distance is 48.32 km.  
> I tried many options and ES always returns 0 results to me.  
> ( I used sense extension above)
> 
> --  
> 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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> To view this discussion on the web visit  
> [https://groups.google.com/d/msgid/elasticsearch/fa9dc0f4-be05-4756-9cfb-3486cdd9a178%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/fa9dc0f4-be05-4756-9cfb-3486cdd9a178%40googlegroups.com)  
> [https://groups.google.com/d/msgid/elasticsearch/fa9dc0f4-be05-4756-9cfb-3486cdd9a178%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/fa9dc0f4-be05-4756-9cfb-3486cdd9a178%40googlegroups.com?utm_medium=email&utm_source=footer)  
> .  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
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/8eac344a-90a5-4edb-87d1-0624abb06058%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/8eac344a-90a5-4edb-87d1-0624abb06058%40googlegroups.com).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [October 19, 2014, 7:17pm UTC](https://discuss.elastic.co/t/geo-distance-filter-always-returns-0-results/20323/4 "2014-10-19T19:17:00Z")

</div>

That's what I said. Your mapping is set for pin and not for location.

--  
David 😉  
Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs

> Le 19 oct. 2014 à 20:17, Driton Alija [dritonalija4@gmail.com](mailto:dritonalija4@gmail.com) a écrit :
> 
> Hi David.
> 
> Thank you for your reply and help.
> 
> No I did the mapping for location not for pin.
> 
> Here is the attachment from the mapping that I did.
> 
> I appreciate your help.
> 
> > On Sunday, October 19, 2014 8:07:12 PM UTC+2, David Pilato wrote:  
> > It sounds like you created a mapping for type pin but sent documents with location type.
> > 
> > I'd check the index creation command. Check the mapping for location.
> > 
> > --  
> > David 😉  
> > Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs
> > 
> > > Le 19 oct. 2014 à 18:51, Driton Alija [driton...@gmail.com](mailto:driton...@gmail.com) a écrit :
> > > 
> > > ## Hi all. I want to be able to search with geo distance in ES 1.3.4. I did geo mapping: POST /geo/ { "mappings":{ "pin" : { "properties" : { "location" : { "type" : "geo\_point" } } } } } Added some data in this format: PUT /geo/location/1 { "pin" : { "location" : { "lat" : 42.4398181, "lon" : 21.466074 }, "text" : "Geolocation distance search" } } Tried to search with geo\_distance filter: POST geo/location/\_search { "query": {"filtered": { "query": { "match\_all": {}}, "filter": { "geo\_distance": { "distance": "500", "distance\_unit": "km", "pin.location": { "lat" : 42.1, "lon" : 21.1 } } } }} } And always getting 0 results even that this distance is 48.32 km. I tried many options and ES always returns 0 results to me. ( I used sense extension above)
> > > 
> > > 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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com).  
> > > To view this discussion on the web visit [https://groups.google.com/d/msgid/elasticsearch/fa9dc0f4-be05-4756-9cfb-3486cdd9a178%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/fa9dc0f4-be05-4756-9cfb-3486cdd9a178%40googlegroups.com).  
> > > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> 
> --  
> 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/8eac344a-90a5-4edb-87d1-0624abb06058%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/8eac344a-90a5-4edb-87d1-0624abb06058%40googlegroups.com).  
> For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
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/41E5AD89-76DD-4FF8-8303-897EEF9D00ED%40pilato.fr](https://groups.google.com/d/msgid/elasticsearch/41E5AD89-76DD-4FF8-8303-897EEF9D00ED%40pilato.fr).  
For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

---

<div class="post-metadata">

**Author:** ![Driton\_Alija](https://avatars.discourse-cdn.com/v4/letter/d/278dde/32.png) [@Driton\_Alija](https://discuss.elastic.co/u/Driton_Alija)\
**Post date:** [October 19, 2014, 8:15pm UTC](https://discuss.elastic.co/t/geo-distance-filter-always-returns-0-results/20323/5 "2014-10-19T20:15:45Z")

</div>

Hi David. Thanks for your reply.I also received a solution from issues in  
Gig Hub repository (I was new to elasticsearch and mixed question place) .  
Here is the link for the others who want to make this example work :  
[Geo distance filter always returns 0 results · Issue #8152 · elastic/elasticsearch · GitHub](https://github.com/elasticsearch/elasticsearch/issues/8152) .Thank you again  
for your fast reply.

On Sunday, October 19, 2014 9:17:41 PM UTC+2, David Pilato wrote:

> That's what I said. Your mapping is set for pin and not for location.
> 
> --  
> David 😉  
> Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs
> 
> Le 19 oct. 2014 à 20:17, Driton Alija \<[driton...@gmail.com](mailto:driton...@gmail.com) \<javascript:\>\>  
> a écrit :
> 
> Hi David.
> 
> Thank you for your reply and help.
> 
> No I did the mapping for location not for pin.
> 
> Here is the attachment from the mapping that I did.
> 
> I appreciate your help.
> 
> [https://lh5.googleusercontent.com/-KlNYMUCpIn8/VEP\_yPU18gI/AAAAAAAAAEM/R1dlp1lMD3Q/s1600/mapping\_geo.PNG](https://lh5.googleusercontent.com/-KlNYMUCpIn8/VEP_yPU18gI/AAAAAAAAAEM/R1dlp1lMD3Q/s1600/mapping_geo.PNG)
> 
> On Sunday, October 19, 2014 8:07:12 PM UTC+2, David Pilato wrote:
> 
> > It sounds like you created a mapping for type pin but sent documents with  
> > location type.
> > 
> > I'd check the index creation command. Check the mapping for location.
> > 
> > --  
> > David 😉  
> > Twitter : @dadoonet / @elasticsearchfr / @scrutmydocs
> > 
> > Le 19 oct. 2014 à 18:51, Driton Alija [driton...@gmail.com](mailto:driton...@gmail.com) a écrit :
> > 
> > Hi all. I want to be able to search with geo distance in ES 1.3.4.  
> > I did geo mapping:  
> > POST /geo/  
> > { "mappings":{  
> > "pin" : {  
> > "properties" : {  
> > "location" : {  
> > "type" : "geo\_point"  
> > }  
> > }  
> > }  
> > }  
> > }  
> > Added some data in this format:  
> > PUT /geo/location/1  
> > {  
> > "pin" : {  
> > "location" : {  
> > "lat" : 42.4398181,  
> > "lon" : 21.466074  
> > },  
> > "text" : "Geolocation distance search"  
> > }  
> > }  
> > Tried to search with geo\_distance filter:  
> > POST geo/location/\_search  
> > {  
> > "query": {"filtered": {  
> > "query": {  
> > "match\_all": {}},  
> > "filter": {  
> > "geo\_distance": {  
> > "distance": "500",  
> > "distance\_unit": "km",  
> > "pin.location": {  
> > "lat" : 42.1,  
> > "lon" : 21.1  
> > }  
> > }  
> > }  
> > }}  
> > }  
> > And always getting 0 results even that this distance is 48.32 km.  
> > I tried many options and ES always returns 0 results to me.  
> > ( I used sense extension above)
> > 
> > --  
> > 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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com).  
> > To view this discussion on the web visit  
> > [https://groups.google.com/d/msgid/elasticsearch/fa9dc0f4-be05-4756-9cfb-3486cdd9a178%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/fa9dc0f4-be05-4756-9cfb-3486cdd9a178%40googlegroups.com)  
> > [https://groups.google.com/d/msgid/elasticsearch/fa9dc0f4-be05-4756-9cfb-3486cdd9a178%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/fa9dc0f4-be05-4756-9cfb-3486cdd9a178%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > .  
> > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).
> > 
> > --  
> > 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 [elasticsearc...@googlegroups.com](mailto:elasticsearc...@googlegroups.com) \<javascript:\>.  
> > To view this discussion on the web visit  
> > [https://groups.google.com/d/msgid/elasticsearch/8eac344a-90a5-4edb-87d1-0624abb06058%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/8eac344a-90a5-4edb-87d1-0624abb06058%40googlegroups.com)  
> > [https://groups.google.com/d/msgid/elasticsearch/8eac344a-90a5-4edb-87d1-0624abb06058%40googlegroups.com?utm\_medium=email&utm\_source=footer](https://groups.google.com/d/msgid/elasticsearch/8eac344a-90a5-4edb-87d1-0624abb06058%40googlegroups.com?utm_medium=email&utm_source=footer)  
> > .  
> > For more options, visit [https://groups.google.com/d/optout](https://groups.google.com/d/optout).

--  
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/af409db3-6b93-4ac0-8cdb-d8f91c2d50b3%40googlegroups.com](https://groups.google.com/d/msgid/elasticsearch/af409db3-6b93-4ac0-8cdb-d8f91c2d50b3%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:55am UTC](https://discuss.elastic.co/t/geo-distance-filter-always-returns-0-results/20323/6 "2017-07-06T00:55:14Z")

</div>


