How to run deo_distance on a document without hardcoding the coordinates

Viewed 9

With a standard geo_distance query, it's required to give the coordinates of the point by which you want to query from. For example, at (40, -70):

"filter": {
  "geo_distance": {
    "distance": "200km",
    "pin.location": {
      "lat": 40,
      "lon": -70
    }
  }
}

However, I'd like to write the query such that the coordinates are pulled from a document. Something like:

"filter": {
  "geo_distance": {
    "distance": "200km",
    "pin.location": "<_id>"
  }
}

Is there a workaround to make this possible? Open to scripting solutions too.

0 Answers
Related