# Geo distance filter with multiple (must or should) keyword

**URL:** <https://discuss.elastic.co/t/geo-distance-filter-with-multiple-must-or-should-keyword/87841>\
**Category:** Elasticsearch\
**Created:** [June 1, 2017, 5:10am UTC](https://discuss.elastic.co/t/geo-distance-filter-with-multiple-must-or-should-keyword/87841 "2017-06-01T05:10:50Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Venugopal\_Ravi](https://avatars.discourse-cdn.com/v4/letter/v/e56c9b/32.png) [@Venugopal\_Ravi](https://discuss.elastic.co/u/Venugopal_Ravi)\
**Post date:** [June 1, 2017, 5:10am UTC](https://discuss.elastic.co/t/geo-distance-filter-with-multiple-must-or-should-keyword/87841/1 "2017-06-01T05:10:50Z")

</div>

I am using elasticsearch with bool/must/filter and in filter using the geo\_distance filter. Here are some sample queries:

Example 1:  
For this query as I am using only one must term with geo filter, I am able to get atleast 1 or more results.

curl -XPOST 'localhost:9200/indexname/\_search?pretty' -H 'Content-Type: application/json' -d'  
{  
"query": {  
"bool" : {  
"must": {  
"term": { "name": "cafe" }  
},  
"filter": {  
"geo\_distance" : {  
"distance" : "20km",  
"pin.coordinates" : {  
"lat" : 13.9291040000,  
"lon" : -70.8269250000  
}  
}  
}  
}  
}  
}'

Example 2:

If I use **multiple must or should** along with the above query it is not displaying any hits/results

curl -XPOST 'localhost:9200/indexname/\_search?pretty' -H 'Content-Type: application/json' -d'  
{  
"query": {  
"bool" : {  
"must": {  
"term": { "name": "cafe" }  
},  
"filter": {  
"geo\_distance" : {  
"distance" : "20km",  
"pin.coordinates" : {  
"lat" : 13.9291040000,  
"lon" : -70.8269250000  
}  
}  
},  
"should" : [  
{ "term" : { "category\_ol" : "cafe" } },  
{ "term" : { "name\_en" : "cafe" } }  
],  
"minimum\_should\_match" : 1,  
"boost" : 1.0  
}  
}  
}'

Anything wrong in the 2nd sample? Please give some solution. TIA

---

<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:** [June 29, 2017, 5:10am UTC](https://discuss.elastic.co/t/geo-distance-filter-with-multiple-must-or-should-keyword/87841/2 "2017-06-29T05:10:56Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
