# Query geo\_distance with distance variable

**URL:** <https://discuss.elastic.co/t/query-geo-distance-with-distance-variable/85198>\
**Category:** Elasticsearch\
**Created:** [May 10, 2017, 7:09am UTC](https://discuss.elastic.co/t/query-geo-distance-with-distance-variable/85198 "2017-05-10T07:09:12Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![JvonRudno](https://avatars.discourse-cdn.com/v4/letter/j/258eb7/32.png) [@JvonRudno](https://discuss.elastic.co/u/JvonRudno)\
**Post date:** [May 10, 2017, 7:09am UTC](https://discuss.elastic.co/t/query-geo-distance-with-distance-variable/85198/1 "2017-05-10T07:09:12Z")

</div>

Hi everybody

I have an index where every document has a field whit an integer that represent a radio value. Now I need to do a geo\_distance query where the parameter "distance" will be variable and depend of the value of the field "radio" in the document.  
With an example perhaps is easier to explain:  
Index:  
"\_source": {  
"customer\_id": 1,  
"geolocation": "49.8523,8.6386",  
"radio": 10,

}  
"\_source": {  
"customer\_id": 2,  
"geolocation": "50.0042,12.0881",  
"radio": 100,  
}

query:  
GET cm\_customers/\_search  
{  
"query": {  
"filtered": {  
"filter": {  
"geo\_distance": {  
"distance": radio \>= distance between fix point in query and geolocation in document  
"geolocation": {  
"lat": 51.16547,  
"lon": 10.4322  
}  
}  
}  
}  
}  
}

The query should select all the documents where the radio field in document \>= distance between the fixpoint in query("51.16547, 10.4322") and the geolocation of the document("50.0042,12.0881"). ==\> this values for the first document.

Is posible to configure a query like this?

In advance thanks a lot for your help!!

Best regards

Jorge von Rudno

---

<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 7, 2017, 7:20am UTC](https://discuss.elastic.co/t/query-geo-distance-with-distance-variable/85198/2 "2017-06-07T07:20:52Z")

</div>

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