Skip to content

Ignore unmapped is not working in geo_shape query #136954

@sirmad007

Description

@sirmad007

Elasticsearch Version

8.15.5

Installed Plugins

No response

Java Version

bundled

OS Version

kubernetes ("name": "Linux","pretty_name": "Ubuntu 20.04.6 LTS","arch": "amd64","version": "5.15.0-156-generic")

Problem Description

Index setup:
we have multiple index inside the system and all have a nested "DU" inside of it, but not all DU have the field "DU.location_position"

Example mapping

{
  "entity_xyz": {
    "mappings": {
      "DU.location_position": {
        "full_name": "DU.location_position",
        "mapping": {
          "location_position": {
            "type": "geo_point"
          }
        }
      }
    }
  }
}

my goal is to replace some deprecated geo_polygon queries with geo_shape queries. And because some of the geo shape can get big, i want to use indexed shapes

old query:

GET /entity_*/_search
{
  "query": {
    "nested": {
      "query": {
        "bool": {
          "must": [
            {
              "geo_polygon": {
                "DU.location_position": {
                  "points": [
                    [
                      -169.40208435058594,
                      -3.1404058933258057
                    ],
                    [
                      -169.40208435058594,
                      83.99121856689453
                    ],
                    [
                      20.51266860961914,
                      83.99121856689453
                    ],
                    [
                      20.51266860961914,
                      -3.1404058933258057
                    ],
                    [
                      -169.40208435058594,
                      -3.1404058933258057
                    ]
                  ]
                },
                **"ignore_unmapped": true**
              }
            }
          ]
        }
      },
      "path": "DU"
    }
  }
}

This is how my new query looks like:

GET /entity_*/_search
{
  "query": {
    "nested": {
      "query": {
        "bool": {
          "must": [
            {
              "geo_shape": {
                "DU.location_position": {
                  "indexed_shape": {
                    "id": "1",
                    "index": "cached_polygon",
                    "path": "shape"
                  },
                  "relation": "within"
                },
                **"ignore_unmapped": true**
              }
            }
          ]
        }
      },
      "path": "DU"
    }
  }
}

for all index where the field "DU.location_position" not exists i got an error

"reason": {
          "type": "query_shard_exception",
          "reason": "failed to find type for field [DU.location_position]",
          "index_uuid": "m2vv83hVRWOIoPc_8bqXfQ",
          "index": "entity_xyz"
        }

Remarks:

  • in the old query version with “geo_polygon” the failures are only happening if i set ignore unmapped to false. if i set it to true the failures go away
  • i would expect setting “ignore_unmapped” to true would ignore unmapped in the new “geo_shape” like in the old “geo_polygon“
  • maybe the problem is triggered because of the "nested" part?

ES version: 8.15.5

Steps to Reproduce

  1. create index_name1 with a nested document and inside a field of type geo_point
  2. create index_name2 with a nested document and the field is missing
  3. execute a geo_shape search over both index (e.g. index_*)

Logs (if relevant)

No response

Metadata

Metadata

Assignees

Labels

:Analytics/GeoIndexing, search aggregations of geo points and shapes>bugTeam:AnalyticsMeta label for analytical engine team (ESQL/Aggs/Geo)

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions