1

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

nonNumericalFloat
  • 1,348
  • 2
  • 15
  • 32
  • For now, as this seems to be not supported by ES at the moment of asking due to lucene restrictions, I will approximate a polygon in my JS frontend before sending data to my backend.(using github.com/gabzim/circle-to-polygon). Anyway, I will leave this question here to be unanswered until ES supports this feature. – nonNumericalFloat Jan 13 '20 at 12:26
  • do you know if there is a fix for this? I am looking for similar functionality – user7922501 Dec 01 '21 at 05:59
  • I don't know If this can be done in newer versions of ES, but for me the solution was to approximate a circle with a polygon. Then you can query the intersections between your circle(actually being a polygon) and other polygons. – nonNumericalFloat Dec 01 '21 at 10:44

0 Answers0