Elasticsearch geo_shape query: Find polygons intersecting/within given circle

1.2k Views Asked by At

ElasticSearch 7.5.1

I'm trying to find all indexed polygons/multipolygons that intersect or lie within a given circle, rather then within a given polygon. My shape is indexed as

"geometry": {
  "type": "geo_shape",
  "tree_levels": 16,
  "strategy": "recursive"
}

My current (polygon) query looks like

   "query": {
        "geo_shape": {
            "geometry": {
                "shape": {
                    "coordinates": [
                        [
                            [
                                130.12509,
                                1.20136
                            ],
                            [
                                130.69336,
                                -9.18887
                            ],
                            [
                                154.02832,
                                -12.72608
                            ],
                            [
                                163.52051,
                                -10.01213
                            ],
                            [
                                141.78762,
                                5.33949
                            ],
                            [
                                130.12509,
                                1.20136
                            ]
                        ]
                    ],
                    "type": "polygon",
                    "relation": "intersects"
                }
            }
        }
    }

I'd rather provide a quer with "type": "circle" if possible, like

"query": {
    "geo_shape": {
        "geometry": {
            "shape": {
                "type": "circle",
                "radius" "5km",
                "coordinates":
                [
                    130.12509,
                    1.20136
                ],
                "relation": "within"
            }
        }
    }
}

I know since breaking changes in V6 circles are somewhat not supported anymore, but is this possible somehow or does ES offer a polygon approximation for a given circle ? Thanks in advance

0

There are 0 best solutions below