# Geo-distance ranges

**URL:** <https://discuss.elastic.co/t/geo-distance-ranges/138368>\
**Category:** Elasticsearch\
**Created:** [July 3, 2018, 11:53am UTC](https://discuss.elastic.co/t/geo-distance-ranges/138368 "2018-07-03T11:53:33Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Csanad\_Vereckei](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/csanad_vereckei/32/32912_2.png) [@Csanad\_Vereckei](https://discuss.elastic.co/u/Csanad_Vereckei)\
**Post date:** [July 3, 2018, 11:53am UTC](https://discuss.elastic.co/t/geo-distance-ranges/138368/1 "2018-07-03T11:53:34Z")

</div>

Hi!

I'm somewhat new to Elastic and however I can now use the geo-distance queries and geo filters, I would like to ask if there is any way to get distance between areas.

What I mean is, say I have a person at X:Y and have a maximum range of 50kms, that this person is willing to travel. Now I have another one at X1:Y1, who says his range is 10kms. Lets say that the two points are exactly 55kms away from each other.

Now I know it sounds weird, but can I find the mentioned user as a viable result for the other one? Like if we had two venn diagrams and since they have an intersection, we have a match.

Thank you for any answers in advance!

---

<div class="post-metadata">

**Author:** ![Igor\_Motov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/igor_motov/32/45193_2.png) [@Igor\_Motov](https://discuss.elastic.co/u/Igor_Motov)\
**Post date:** [July 6, 2018, 1:45pm UTC](https://discuss.elastic.co/t/geo-distance-ranges/138368/2 "2018-07-06T13:45:42Z")

</div>

How about combining two geo-distance queries in one [bool query](https://www.elastic.co/guide/en/elasticsearch/reference/6.3/query-dsl-bool-query.html)?

---

<div class="post-metadata">

**Author:** ![Csanad\_Vereckei](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/csanad_vereckei/32/32912_2.png) [@Csanad\_Vereckei](https://discuss.elastic.co/u/Csanad_Vereckei)\
**Post date:** [July 9, 2018, 6:11am UTC](https://discuss.elastic.co/t/geo-distance-ranges/138368/3 "2018-07-09T06:11:02Z")

</div>

Thanks for the quick reply and the idea. We'll try it and see if it fits our needs, but seems promising.

---

<div class="post-metadata">

**Author:** ![Csanad\_Vereckei](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/csanad_vereckei/32/32912_2.png) [@Csanad\_Vereckei](https://discuss.elastic.co/u/Csanad_Vereckei)\
**Post date:** [July 12, 2018, 7:23am UTC](https://discuss.elastic.co/t/geo-distance-ranges/138368/4 "2018-07-12T07:23:06Z")

</div>

Not sure, if you ment to combine two (or more) geo\_distance filters, but doing so within a "must" array did the trick. So if anyone tries to achieve something similar, I can confirm this works.

Thank you very much, again, for the quick help!

---

<div class="post-metadata">

**Author:** ![Igor\_Motov](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/igor_motov/32/45193_2.png) [@Igor\_Motov](https://discuss.elastic.co/u/Igor_Motov)\
**Post date:** [July 12, 2018, 2:10pm UTC](https://discuss.elastic.co/t/geo-distance-ranges/138368/5 "2018-07-12T14:10:35Z")

</div>

If you want intersection, then you have to, indeed, put both queries into the `must` array.

---

<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:** [August 9, 2018, 2:10pm UTC](https://discuss.elastic.co/t/geo-distance-ranges/138368/6 "2018-08-09T14:10:37Z")

</div>

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