# Geo\_distance\_range is obsolete?

**URL:** <https://discuss.elastic.co/t/geo-distance-range-is-obsolete/241729>\
**Category:** Elasticsearch\
**Created:** [July 17, 2020, 10:15pm UTC](https://discuss.elastic.co/t/geo-distance-range-is-obsolete/241729 "2020-07-17T22:15:54Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ClubberLang](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/clubberlang/32/72169_2.png) [@ClubberLang](https://discuss.elastic.co/u/ClubberLang)\
**Post date:** [July 17, 2020, 10:15pm UTC](https://discuss.elastic.co/t/geo-distance-range-is-obsolete/241729/1 "2020-07-17T22:15:55Z")

</div>

Hi,

In old ES we had the function "geo\_distance\_range" that allows to filter everything between, let's say by example, 20k and 50km.

When I look at the documentation, they propose to use geo distance aggregations:

> **[Geo distance range Query | Elasticsearch Guide \[7.5\] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/7.5/query-dsl-geo-distance-range-query.html)**

But, how can I use the aggregation to create such filter, I have search for an example, try during hours to achieve such query... no way !

Here is an example of query:

> "query": {  
> "bool" : {  
> "must" : {  
> "match\_all" : {}  
> },  
> "filter" : {  
> "geo\_distance" : {  
> "distance" : "50km",  
> "geoLocations" : [{{longitude}}, {{latitude}}]  
> }  
> }  
> }  
> }

If someone has an idea to help ?

Thanks a lot 😉

---

<div class="post-metadata">

**Author:** ![Ignacio\_Vera](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ignacio_vera/32/36674_2.png) [@Ignacio\_Vera](https://discuss.elastic.co/u/Ignacio_Vera)\
**Post date:** [July 20, 2020, 10:36am UTC](https://discuss.elastic.co/t/geo-distance-range-is-obsolete/241729/2 "2020-07-20T10:36:30Z")

</div>

Cannot you use a `must_not` clause for the inner ring to remove those hits?

---

<div class="post-metadata">

**Author:** ![ClubberLang](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/clubberlang/32/72169_2.png) [@ClubberLang](https://discuss.elastic.co/u/ClubberLang)\
**Post date:** [July 20, 2020, 5:12pm UTC](https://discuss.elastic.co/t/geo-distance-range-is-obsolete/241729/3 "2020-07-20T17:12:32Z")

</div>

Thanks @Ignacio_Vera,

This way it work 😉

---

<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 17, 2020, 5:12pm UTC](https://discuss.elastic.co/t/geo-distance-range-is-obsolete/241729/4 "2020-08-17T17:12:37Z")

</div>

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