Fix effective_mappings field to remove _doc wrapper#4
Open
augment-app-staging[bot] wants to merge 1 commit intomainfrom
Open
Fix effective_mappings field to remove _doc wrapper#4augment-app-staging[bot] wants to merge 1 commit intomainfrom
augment-app-staging[bot] wants to merge 1 commit intomainfrom
Conversation
The effective_mappings field in the get data stream API response
(GET /_data_stream/{name}/_mappings) and update data stream mappings
API response (PUT /_data_stream/{name}/_mappings) was incorrectly
including a _doc wrapper at the top level.
According to the API specification, effective_mappings should contain
the mapping content directly (e.g., {\properties\: {...}}) without
being wrapped in {\_doc\: {\properties\: {...}}}.
This fix strips the _doc wrapper when serializing effective_mappings
in the toXContent methods of:
- GetDataStreamMappingsAction.DataStreamMappingsResponse
- UpdateDataStreamMappingsAction.DataStreamMappingsResponse
Updated tests to expect the correct format without the _doc wrapper.
Fixes: https://augment-wic8570.slack.com/archives/C0AG2MXKEQJ/p1772152880428979
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
This PR fixes the
effective_mappingsfield in the get data stream API response which was incorrectly including a_docwrapper at the top level.Problem
The
effective_mappingsfield in the following API responses was wrapped in a_docobject:GET /_data_stream/{name}/_mappings(get data stream mappings)PUT /_data_stream/{name}/_mappings(update data stream mappings)According to the API specification,
effective_mappingsshould contain the mapping content directly (e.g.,{"properties": {...}, "_data_stream_timestamp": {...}}) without being wrapped in{"_doc": {"properties": {...}, ...}}.Solution
The fix strips the
_docwrapper when serializingeffective_mappingsin thetoXContentmethods of:GetDataStreamMappingsAction.DataStreamMappingsResponseUpdateDataStreamMappingsAction.DataStreamMappingsResponseThe logic checks if the uncompressed effective mappings map contains exactly one key named
_doc, and if so, unwraps it before serializing.Changes
Modified
GetDataStreamMappingsAction.java: Added logic to strip the_docwrapper fromeffective_mappingsin thetoXContentmethod.Modified
UpdateDataStreamMappingsAction.java: Added the same logic to strip the_docwrapper fromeffective_mappingsin thetoXContentmethod.Updated test file
250_data_stream_mappings.yml: Changed all test assertions fromeffective_mappings._doc.propertiestoeffective_mappings.propertiesto match the corrected output format.Testing
All existing YAML REST tests in
modules/data-streams/src/yamlRestTest/resources/rest-api-spec/test/data_stream/250_data_stream_mappings.ymlhave been updated and pass successfully.Related
Note: This PR was not assigned to anyone as it was triggered by an automated evaluation bot.