# Finding all documents nearby another in one request

**URL:** <https://discuss.elastic.co/t/finding-all-documents-nearby-another-in-one-request/134666>\
**Category:** Elasticsearch\
**Created:** [June 5, 2018, 4:30pm UTC](https://discuss.elastic.co/t/finding-all-documents-nearby-another-in-one-request/134666 "2018-06-05T16:30:04Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![GeoffreyOnRails](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/geoffreyonrails/32/31138_2.png) [@GeoffreyOnRails](https://discuss.elastic.co/u/GeoffreyOnRails)\
**Post date:** [June 5, 2018, 4:30pm UTC](https://discuss.elastic.co/t/finding-all-documents-nearby-another-in-one-request/134666/1 "2018-06-05T16:30:04Z")

</div>

I have multiple documents containing a geo-spatial location. I'd like to make a query finding all the documents (let's say B,C,D) whose location is below a given distance of another document (A).  
All my document have a location of "type": "geo\_point", and I'm able to find all the one nearby a given point using that filter :

```
            "filter" : {
                "geo_distance" : {
                    "distance" : "{{radius}}",
                    "location" : {
                        "lat" : "{{lat}}",
                        "lon" : "{{lon}}"

```

However, to get the lat lon in my request, I need to make a request first requesting the coordinates of document A.

Is there a query (in the spirits of the terms query) that would allow me to do something like this?

```
            "filter" : {
                "geo_distance" : {
                    "distance" : "{{radius}}",
                    "location" : {
                               terms:{ "id" : "A", "path" : "location"}

```

Thanks in advance

---

<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:** [July 3, 2018, 4:30pm UTC](https://discuss.elastic.co/t/finding-all-documents-nearby-another-in-one-request/134666/2 "2018-07-03T16:30:09Z")

</div>

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