Point in Polygon without CONTAINS spatial relation operator (now DEPRECATED)

TL;DR : geo_shape CONTAINS operation is deprecated and I don't see an equivalent in the docs. I'm trying to find all the polygons that contain a coordinate point.

I worked with Polygon indexation and PIP (Point in Polygon) operations. To find all polygons that contained a given coordinate (point) we used this query:

query["query"]["bool"]["filter"] = {
    "geo_shape": {
        "location": {
            "shape": {
                "type": "point",
                "coordinates" : [longitude, latitude]
            },
            "relation": "contains"
        }
    }
}

I'm currently working in a new project that does something similar, so I decided to use the same query but it turns out that this relation has been deprecated. Reading the docs does not help so I decided to do some testing with a small subset of our current data (it's a large dataset) and intersects seems to be working well.

query["query"]["bool"]["filter"] = {
    "geo_shape": {
        "location": {
            "shape": {
                "type": "point",
                "coordinates" : [longitude, latitude]
            },
            "relation": "intersects"
        }
    }
}

Now, can intersects and contains be considered equivalent from a Point in Polygon point of view?

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.