Get documents with a location + radius that contain a provided geopoint

First up, thanks for providing such an awesome post, with full reproduction!

Second, the docs could make this clearer, but this works;

GET /sen/_search
{
  "query": {
    "bool": {
      "must": {
        "match_all": {}
      },
      "filter": {
        "geo_shape": {
          "location": {
            "shape": {
              "type": "point",
              "coordinates": 
                [ -117.780552,35.706161
              ]
            },
            "relation": "contains"
          }
        }
      }
    }
  }
}

Basically I changed the relation to a contains, because you are looking for a point that is contained within that shape. within and contains both mean; does the queried shape entirely exist within the indexed shape. But the former is for shapes, the latter for points.
You may want to consider looking at intersects as well.

I'll raise a GH issue to get the docs updated to make all this clearer too.

1 Like