# Geo Polygon Query retuns nothing

**URL:** https://discuss.elastic.co/t/geo-polygon-query-retuns-nothing/174758
**Category:** Elasticsearch
**Created:** [April 1, 2019, 10:35am UTC](https://discuss.elastic.co/t/geo-polygon-query-retuns-nothing/174758 "2019-04-01T10:35:51Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Yandex\_Art](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yandex_art/32/43204_2.png) [@Yandex\_Art](https://discuss.elastic.co/u/Yandex_Art)
#### Post date: [April 1, 2019, 10:35am UTC](https://discuss.elastic.co/t/geo-polygon-query-retuns-nothing/174758/1 "2019-04-01T10:35:51Z")

</div>

**1. Сreat new using the following request:**

```
PUT /test?pretty
{
    "mappings": {
        "tst": {
        "properties": {
            "nm":{
                "type":"text"
                },
            "loc": {
                "type": "geo_point"
                }
            }  
        }
    }
}

```

**2. Geting index Information using `get /test` . The result is:**

```
{
  "test" : {
    "aliases" : { },
    "mappings" : {
      "tst" : {
        "properties" : {
          "loc" : {
            "type" : "geo_point"
          },
          "nm" : {
            "type" : "text"
          }
        }
      }
    },
    "settings" : {
      "index" : {
        "creation_date" : "1554110780623",
        "number_of_shards" : "5",
        "number_of_replicas" : "1",
        "uuid" : "M8_x6t7iSKa0Xpm_lDbAcQ",
        "version" : {
          "created" : "6070099"
        },
        "provided_name" : "test"
      }
    }
  }
}

```

**3. Adding new document using then following request:**

```
post /test/tst
{
  "nm":"Test1",
  "loc":"37,55"
}

```

**4. And now I perform a query using a polygon that exactly contains the point 37,55:**

```
GET /test/tst/_search
{
    "query": {
        "bool" : {
            "must" : {
                "match_all" : {}
            },
            "filter" : {
                "geo_polygon" : {
                    "loc" : {
                        "points" : [[36,54],
                                    [36,56],
                                    [38,56],
                                    [38,54],
                                    [36,54]]
                    }
                }
            }
        }
    }
}

```

The result is:

```
        {
          "took" : 1,
          "timed_out" : false,
          "_shards" : {
            "total" : 5,
            "successful" : 5,
            "skipped" : 0,
            "failed" : 0
          },
          "hits" : {
            "total" : 0,
            "max_score" : null,
            "hits" : []
          }
        }

```

**What am i doing wrong?**

---

<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: [April 1, 2019, 10:48am UTC](https://discuss.elastic.co/t/geo-polygon-query-retuns-nothing/174758/2 "2019-04-01T10:48:01Z")

</div>

As you can see in the `geo_point` documentation:

[https://www.elastic.co/guide/en/elasticsearch/reference/current/geo-point.html#geo-point](https://www.elastic.co/guide/en/elasticsearch/reference/current/geo-point.html#geo-point)

There is a warning about the points expressed as arrays or string. The order is defined by [lat, lon].

On the other hand, in the `geo_polygon` query, the polygon is expressed as [lon, lat].

[https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-geo-polygon-query.html#\_lat\_long\_as\_array](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-geo-polygon-query.html#_lat_long_as_array)

You need to order your data and query following those conventions.

---

<div class="post-metadata">

### Author: ![Yandex\_Art](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/yandex_art/32/43204_2.png) [@Yandex\_Art](https://discuss.elastic.co/u/Yandex_Art)
#### Post date: [April 1, 2019, 10:54am UTC](https://discuss.elastic.co/t/geo-polygon-query-retuns-nothing/174758/3 "2019-04-01T10:54:41Z")

</div>

sorry, did not pay attention to the comments, thanks for the tip

---

<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: [April 29, 2019, 10:54am UTC](https://discuss.elastic.co/t/geo-polygon-query-retuns-nothing/174758/4 "2019-04-29T10:54:51Z")

</div>

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