elasticsearch icon indicating copy to clipboard operation
elasticsearch copied to clipboard

Validating mappings when simulate ingest is called

Open masseyke opened this issue 11 months ago • 1 comments

This adds functionality to the simulate ingest API (#101409). If the index exists when the ingest simulate API is called that the transformed documents would be indexed into if this were not a simulation, then it now reports any mapping validations that would occur. For example, if we have an index named test-index with strict mappings and a single property named foo, then:

POST _ingest/_simulate?pretty&index=test-index
{
  "docs": [
    {
      "_source": {
        "foob": "bar"
      }
    },
    {
      "_source": {
        "foo": "baz"
      }
    }
  ]
}

would result in something like:

{
    "docs" : [
      {
        "doc" : {
          "_id" : "id",
          "_index" : "test-index",
          "_version" : -3,
          "_source" : {
            "foob" : "bar"
          },
          "executed_pipelines" : [
            "test-pipeline"
          ],
          "error" : {
            "type" : "strict_dynamic_mapping_exception",
            "reason" : "[1:9] mapping set to strict, dynamic introduction of [foob] within [_doc] is not allowed"
          }
        }
      },
      {
        "doc" : {
          "_id" : "id",
          "_index" : "test-index",
          "_version" : -3,
          "_source" : {
            "foo" : "baz"
          },
          "executed_pipelines" : [
            "test-pipeline"
          ]
        }
      }
    ]
}

masseyke avatar Mar 18 '24 21:03 masseyke

Hi @masseyke, I've created a changelog YAML for you.

elasticsearchmachine avatar Mar 18 '24 21:03 elasticsearchmachine

Closed in favor of #110606

masseyke avatar Jul 08 '24 19:07 masseyke