0

I have a list geoshape documents like this:

{
    "location" : {
        "type" : "circle",
        "coordinates" : [-45.0, 45.0],
        "radius" : "8000m"
    }
 }

Given a lat/lng, I want to find all the documents that this lat/lng is in.

samol
  • 18,950
  • 32
  • 88
  • 127

1 Answers1

2

You need to use a geo_shape query like this one:

{
  "query": {
    "bool": {
      "filter": {
        "geo_shape": {
          "location": {
            "shape": {
              "type": "point",
              "coordinates": [ -77.03653, 38.897676 ]   <-- lon/lat to search
            },
            "relation": "contains"                      <-- use the contains relationship
          }
        }
      }
    }
  }
}

In the coordinates parameter make sure to set longitude before latitude and not the other way around (thanks GeoJSON)

Val
  • 207,596
  • 13
  • 358
  • 360