# Point in Polygon query doesn't match document

**URL:** <https://discuss.elastic.co/t/point-in-polygon-query-doesnt-match-document/152133>\
**Category:** Elasticsearch\
**Created:** [October 11, 2018, 9:43pm UTC](https://discuss.elastic.co/t/point-in-polygon-query-doesnt-match-document/152133 "2018-10-11T21:43:10Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ganesh\_Kudva](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ganesh_kudva/32/41942_2.png) [@Ganesh\_Kudva](https://discuss.elastic.co/u/Ganesh_Kudva)\
**Post date:** [October 11, 2018, 9:43pm UTC](https://discuss.elastic.co/t/point-in-polygon-query-doesnt-match-document/152133/1 "2018-10-11T21:43:10Z")

</div>

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

This is my index mapping

```auto
{
  "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.

```auto
{
  "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

```auto
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

 ![location_query](https://us1.discourse-cdn.com/elastic/original/3X/d/7/d787e221de7dacc6fd43b39830a3a5f9b77d8e6d.jpeg)

---

<div class="post-metadata">

**Author:** ![Ignacio\_Vera](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ignacio_vera/32/36674_2.png) [@Ignacio\_Vera](https://discuss.elastic.co/u/Ignacio_Vera)\
**Post date:** [October 12, 2018, 9:12am UTC](https://discuss.elastic.co/t/point-in-polygon-query-doesnt-match-document/152133/2 "2018-10-12T09:12:24Z")

</div>

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

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/3/e/3ee9c1f52f666254540c5f1d2137a9bb8c1e047c.jpeg)

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.

---

<div class="post-metadata">

**Author:** ![Ganesh\_Kudva](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ganesh_kudva/32/41942_2.png) [@Ganesh\_Kudva](https://discuss.elastic.co/u/Ganesh_Kudva)\
**Post date:** [October 18, 2018, 2:26pm UTC](https://discuss.elastic.co/t/point-in-polygon-query-doesnt-match-document/152133/3 "2018-10-18T14:26:53Z")

</div>

Hey Ignacio,

Thanks for the response.

Yeah looks like it was a mistake on my part.

Thanks,  
Ganesh

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [November 15, 2018, 2:26pm UTC](https://discuss.elastic.co/t/point-in-polygon-query-doesnt-match-document/152133/4 "2018-11-15T14:26:55Z")

</div>

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