From 63f1fb49d5cc5f99d5c48086b4007d36d8855e83 Mon Sep 17 00:00:00 2001 From: Keith Massey Date: Mon, 28 Jul 2025 16:51:29 -0500 Subject: [PATCH 1/3] Fixing handling of subobject mappings in simulate ingest API --- .../test/ingest/80_ingest_simulate.yml | 49 +++++++++++++++++++ .../bulk/TransportSimulateBulkAction.java | 2 +- 2 files changed, 50 insertions(+), 1 deletion(-) diff --git a/qa/smoke-test-ingest-with-all-dependencies/src/yamlRestTest/resources/rest-api-spec/test/ingest/80_ingest_simulate.yml b/qa/smoke-test-ingest-with-all-dependencies/src/yamlRestTest/resources/rest-api-spec/test/ingest/80_ingest_simulate.yml index ba4e73f0c5e09..997a15de287bd 100644 --- a/qa/smoke-test-ingest-with-all-dependencies/src/yamlRestTest/resources/rest-api-spec/test/ingest/80_ingest_simulate.yml +++ b/qa/smoke-test-ingest-with-all-dependencies/src/yamlRestTest/resources/rest-api-spec/test/ingest/80_ingest_simulate.yml @@ -1740,3 +1740,52 @@ setup: - match: { docs.0.doc._source.abc: "sfdsfsfdsfsfdsfsfdsfsfdsfsfdsf" } - match: { docs.0.doc.ignored_fields: [ {"field": "abc"} ] } - not_exists: docs.0.doc.error + +--- +"Test ingest simulate with mapping addition on subobjects": + + - skip: + features: + - headers + - allowed_warnings + + - do: + indices.put_index_template: + name: subobject-template + body: + index_patterns: subobject-index* + template: + mappings: + properties: + a.b: + type: match_only_text + + # Here we provide a mapping_substitution to the subobject, and make sure that it is applied rather than throwing an + # exception. + - do: + headers: + Content-Type: application/json + simulate.ingest: + body: > + { + "docs": [ + { + "_index": "subobject-index-1", + "_id": "AZgsHA0B41JjTOmNiBKC", + "_source": { + "a.b": "some text" + } + } + ], + "mapping_addition": { + "properties": { + "a.b": { + "type": "keyword" + } + } + } + } + - length: { docs: 1 } + - match: { docs.0.doc._index: "subobject-index-1" } + - match: { docs.0.doc._source.a\.b: "some text" } + - not_exists: docs.0.doc.error diff --git a/server/src/main/java/org/elasticsearch/action/bulk/TransportSimulateBulkAction.java b/server/src/main/java/org/elasticsearch/action/bulk/TransportSimulateBulkAction.java index ac807bf1d752c..0775c541e1c41 100644 --- a/server/src/main/java/org/elasticsearch/action/bulk/TransportSimulateBulkAction.java +++ b/server/src/main/java/org/elasticsearch/action/bulk/TransportSimulateBulkAction.java @@ -351,7 +351,7 @@ private Collection validateUpdatedMappings( .putMapping(new MappingMetadata(updatedMappings)) .build(); Engine.Index result = indicesService.withTempIndexService(originalIndexMetadata, indexService -> { - indexService.mapperService().merge(updatedIndexMetadata, MapperService.MergeReason.MAPPING_UPDATE); + indexService.mapperService().merge(updatedIndexMetadata, MapperService.MergeReason.INDEX_TEMPLATE); return IndexShard.prepareIndex( indexService.mapperService(), sourceToParse, From 361acd935c77e47b2647effcb84052fde5e599c3 Mon Sep 17 00:00:00 2001 From: Keith Massey Date: Mon, 28 Jul 2025 16:55:24 -0500 Subject: [PATCH 2/3] Update docs/changelog/132046.yaml --- docs/changelog/132046.yaml | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 docs/changelog/132046.yaml diff --git a/docs/changelog/132046.yaml b/docs/changelog/132046.yaml new file mode 100644 index 0000000000000..3470fd8c443e5 --- /dev/null +++ b/docs/changelog/132046.yaml @@ -0,0 +1,6 @@ +pr: 132046 +summary: Fixing handling of subobject mappings in simulate ingest API +area: Ingest Node +type: bug +issues: + - 131608 From dde0cca716067b981c757d4a16befe72e402035d Mon Sep 17 00:00:00 2001 From: Keith Massey Date: Mon, 28 Jul 2025 17:13:42 -0500 Subject: [PATCH 3/3] Update docs/changelog/132046.yaml --- docs/changelog/132046.yaml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/docs/changelog/132046.yaml b/docs/changelog/132046.yaml index 3470fd8c443e5..f2a6230127b73 100644 --- a/docs/changelog/132046.yaml +++ b/docs/changelog/132046.yaml @@ -2,5 +2,4 @@ pr: 132046 summary: Fixing handling of subobject mappings in simulate ingest API area: Ingest Node type: bug -issues: - - 131608 +issues: []