Point in Polygon query doesn't match document


(Ganesh Kudva) #1

I am trying to perform a Point in Polygon query with latest Elasticsearch(version 6.2.4).

This is my index mapping

{
  "check": {
    "mappings": {
      "doc": {
        "properties": {
          "location": {
            "type": "geo_shape"
          }
        }
      }
    }
  }
}

location describes the contour in 19 latitude longitude pairs
I only have one document in the index.

{
  "took": 1,
  "timed_out": false,
  "_shards": {
    "total": 5,
    "successful": 5,
    "skipped": 0,
    "failed": 0
  },
  "hits": {
    "total": 1,
    "max_score": 1,
    "hits": [
      {
        "_index": "check",
        "_type": "doc",
        "_id": "1",
        "_score": 1,
        "_source": {
          "location": "POLYGON((-121.3606 38.118,-121.2137 38.097,-121.1175 38.007,-121.0795 37.906,-121.171 37.805,-121.171 37.752,-121.1939 37.702,-121.2361 37.661,-121.2975 37.641,-121.3606 37.638,-121.4186 37.652,-121.466 37.679,-121.5154 37.707,-121.5501 37.752,-121.5546 37.805,-121.6475 37.909,-121.605 38.008,-121.5078 38.098,-121.3606 38.118))"
        }
      }
    ]
  }
}

I am performing this query

GET check/doc/_search
{
  "query": {
        "geo_shape": {
          "location": {
            "relation": "intersects",
            "shape": {
              "type": "point",
              "coordinates": [
                -121.935791, 37.702152
                ]
            }
          }
        }
  }
}

The query returns zero documents. I tried with both relation as intersects and contains , still zero results.
If I draw the location contour on Google Maps, I can clearly see that the query point(long:-121.935791, lat:37.702152) is clearly within the location contour


(Ignacio Vera) #2

I have plotted the data provided and the point seems to be outside of the polygon.

Could you check again because the polygon shown in your plot does not seem to be the same polygon you are indexing in your example.


(Ganesh Kudva) #3

Hey Ignacio,

Thanks for the response.

Yeah looks like it was a mistake on my part.

Thanks,
Ganesh


(system) #4

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