BUG: Ignore unmapped is not working in geo polygon query (ES 8.15.5)

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“

ES version: 8.15.5

Thanks for flagging @ma_br! Welcome to the community. Have you raised a GitHub issue for this bug?

Let me know!

It is indeed a bug. I opened Fix ignore_unmapped setting when using geo_shape query with a pre-indexed shape by iverase · Pull Request #136961 · elastic/elasticsearch · GitHub