Skip to content

Fixing handling of subobject mappings in simulate ingest API #132046

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
Closed
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 6 additions & 0 deletions docs/changelog/132046.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
pr: 132046
summary: Fixing handling of subobject mappings in simulate ingest API
area: Ingest Node
type: bug
issues:
- 131608
Original file line number Diff line number Diff line change
Expand Up @@ -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
Original file line number Diff line number Diff line change
Expand Up @@ -351,7 +351,7 @@ private Collection<String> 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);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm… I'm worried we kind of want both behaviors right? The MAPPING_UPDATE one is if we were to update the mapping via the API, while the INDEX_TEMPLATE one is for updating the template. Do we know for sure what the intent is on the user's side?

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

My thinking was that if a user wanted to simulate this change, they'd be doing it through an index-template-like update rather than a mapping update, since this change just fails with a mapping update. This API is meant to simulate what would happen if the index had this mapping change, rather than what would happen if I attempted to make this mapping change.

return IndexShard.prepareIndex(
indexService.mapperService(),
sourceToParse,
Expand Down
Loading