Skip to content

Ingest simulate: mapping_addition doesn't work for subobjects #131608

@flash1293

Description

@flash1293

Elasticsearch Version

main

Installed Plugins

No response

Java Version

bundled

OS Version

macos 15.5

Problem Description

When using the ingest simulate API with mapping additions, the mapping additions are not applied correctly to sub-objects - see steps to reproduce

Steps to Reproduce

Assume an index template like this:

PUT _index_template/myt
{
  "index_patterns": [
    "mytest-*"
  ],
  "composed_of": [],
  "template": {
    "mappings": {
      "properties": {
        "a.b": {
          "type": "match_only_text"
        }
      }
    }
  }
}

I now want to simulate changing a.b. to keyword:

POST _ingest/_simulate
{
  "docs": [
    {
      "_index": "mytest-default",
      "_id": "AZgsHA0B41JjTOmNiBKC",
      "_source": {
        "a.b": "error test"
      }
    }
  ],
  "mapping_addition": {
    "properties": {
      "a.b": {
        "type": "keyword"
      }
    }
  }
}

However, this fails with

{
          "type": "mapper_parsing_exception",
          "reason": "Failed to parse mapping: mapper [a.b] cannot be changed from type [match_only_text] to [keyword]",
          "caused_by": {
            "type": "illegal_argument_exception",
            "reason": "mapper [a.b] cannot be changed from type [match_only_text] to [keyword]"
          }
        }

If I'm mapping ab instead of a.b, everything works as expected.

Logs (if relevant)

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions