Lost with geo query

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.

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

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

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