# Lost with geo query

**URL:** https://discuss.elastic.co/t/lost-with-geo-query/136929
**Category:** Elasticsearch
**Created:** [June 21, 2018, 6:23pm UTC](https://discuss.elastic.co/t/lost-with-geo-query/136929 "2018-06-21T18:23:08Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![Akli](https://avatars.discourse-cdn.com/v4/letter/a/82dd89/32.png) [@Akli](https://discuss.elastic.co/u/Akli)
#### Post date: [June 21, 2018, 6:23pm UTC](https://discuss.elastic.co/t/lost-with-geo-query/136929/1 "2018-06-21T18:23:08Z")

</div>

Hi elastic experts,

I am experiencing some troubles making the following geo query to work:

```
GET grille_arome_001/gridpt/_search
{
  "query": {
       "bool": {
		"filter":
		  {
                        "geo_shape": {
                                 "location": {
                                    "relation": "within",
                                    "indexed_shape": { 
                                   "index": "geographie",
                                   "type": "parc_eolien",
                                   "id": 1,
                                   "path": "location"
                      }
                }
      }
}
}
}
}

```

It always returns 0 match with the following input data:

grid index

```
PUT grille_arome_001_test
{
    "mappings": {
     "gridpt": {
       "properties": {
      "location": {
        "type": "geo_shape",
        "tree": "quadtree",
        "precision": "1100.0m"
      }
    }
  }
}
}

```

grid point sample data

```
PUT grille_arome_001_test/gridpt/1
{
  "location": {
  "type": "envelope",
  "coordinates": [
    [
      50.05,
      1.86
    ],
    [
      50.06,
      1.87
    ]
  ]
}
}

```

geographie index

```
PUT geographie
{
"mappings": {
  "parc_eolien": {
    "properties": {
      "idr": {
        "type": "keyword"
      },
      "location": {
        "type": "geo_shape",
        "tree": "quadtree",
        "precision": "1.0m"
      }
    }
  }
}
}

```

geographie sample data

```
PUT geographie/parc_eolien/1
{
"idr": "E.SOM",
"location": {
  "type": "point",
  "coordinates": [
    1.87173,
    50.0542
  ]
}
}

```

Any help on this problem would be really appreciated.

---

<div class="post-metadata">

### Author: ![Akli](https://avatars.discourse-cdn.com/v4/letter/a/82dd89/32.png) [@Akli](https://discuss.elastic.co/u/Akli)
#### Post date: [June 23, 2018, 6:17am UTC](https://discuss.elastic.co/t/lost-with-geo-query/136929/2 "2018-06-23T06:17:45Z")

</div>

OK, I've found where I was making a mistake. I was inverting lat and lon order in the polygon arrays.

As explained here in the Elasticsearch documentation: [Geopoint field type | Elasticsearch Guide [8.11] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/current/geo-point.html)

> Please note that string geo-points are ordered as lat,lon, while array geo-points are ordered as the reverse: lon,lat.

---

<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: [July 21, 2018, 6:17am UTC](https://discuss.elastic.co/t/lost-with-geo-query/136929/3 "2018-07-21T06:17:51Z")

</div>

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