# Query filter with variable geo\_distance

**URL:** <https://discuss.elastic.co/t/query-filter-with-variable-geo-distance/230914>\
**Category:** Elasticsearch\
**Created:** [May 4, 2020, 3:13am UTC](https://discuss.elastic.co/t/query-filter-with-variable-geo-distance/230914 "2020-05-04T03:13:23Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Joannes\_Noel](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/joannes_noel/32/67610_2.png) [@Joannes\_Noel](https://discuss.elastic.co/u/Joannes_Noel)\
**Post date:** [May 4, 2020, 3:13am UTC](https://discuss.elastic.co/t/query-filter-with-variable-geo-distance/230914/1 "2020-05-04T03:13:23Z")

</div>

I have an interesting situation. I am building an app where sellers post items with geo\_point and market\_radius field. The market\_radius field determines how far the seller can entertain a buyer. if seller says he/she will only entertain buyers from within 80km then the buyers further than 80km will never see the item.

is it possible to filter results by a variable geo\_distance?

![image](https://us1.discourse-cdn.com/elastic/original/3X/1/b/1bbc88941edeaf73ea589555c58b037625fca25b.png)

I want the value of geo\_distance be coming from a document rather than fixed value.

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [May 4, 2020, 3:47am UTC](https://discuss.elastic.co/t/query-filter-with-variable-geo-distance/230914/2 "2020-05-04T03:47:04Z")

</div>

I may be misunderstanding your setup, but `distance` is what you specify, so you can change it to whatever you want. Is the example you are showing from your code, or are you using a script there?

Also please don't post pictures of text, they are difficult to read, impossible to search, difficult to replicate, and some people may not be even able to see them 🙂

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [May 4, 2020, 3:56am UTC](https://discuss.elastic.co/t/query-filter-with-variable-geo-distance/230914/3 "2020-05-04T03:56:21Z")

</div>

As you know these values when you index the document, why don’t you index a geo shape representing the area the product is available in and then search for shapes that include the location of the buyer?

---

<div class="post-metadata">

**Author:** ![Joannes\_Noel](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/joannes_noel/32/67610_2.png) [@Joannes\_Noel](https://discuss.elastic.co/u/Joannes_Noel)\
**Post date:** [May 4, 2020, 4:28am UTC](https://discuss.elastic.co/t/query-filter-with-variable-geo-distance/230914/4 "2020-05-04T04:28:18Z")

</div>

it is just for presentation of what I am trying to achieve. I needed the part on red arrow to be a data coming from the document. it is not a working code because it is not possible. sorry

---

<div class="post-metadata">

**Author:** ![Joannes\_Noel](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/joannes_noel/32/67610_2.png) [@Joannes\_Noel](https://discuss.elastic.co/u/Joannes_Noel)\
**Post date:** [May 4, 2020, 4:28am UTC](https://discuss.elastic.co/t/query-filter-with-variable-geo-distance/230914/5 "2020-05-04T04:28:52Z")

</div>

actually, I think this is the solution. I will try it. 🙂 thanks a lot man!

---

<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 1, 2020, 4:29am UTC](https://discuss.elastic.co/t/query-filter-with-variable-geo-distance/230914/6 "2020-06-01T04:29:02Z")

</div>

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