Skip to content

Strip _doc wrapper from effective_mapping field in API responses#3

Open
augment-app-staging[bot] wants to merge 1 commit intoeval-tag-134005-branchfrom
eval-767c691a
Open

Strip _doc wrapper from effective_mapping field in API responses#3
augment-app-staging[bot] wants to merge 1 commit intoeval-tag-134005-branchfrom
eval-767c691a

Conversation

@augment-app-staging
Copy link

Problem

The effective_mapping field in the get data stream API response and simulate ingest API response was incorrectly including a _doc wrapper at the top level, but the spec says it should not have this wrapper. The _doc type placeholder needs to be stripped from the effective mapping output.

Solution

This PR strips the _doc wrapper from effective mappings in API responses by applying the same pattern used in Template.reduceMapping().

Changes Made:

  1. SimulateIndexResponse.java - Added logic to strip _doc wrapper in innerToXContent() method
  2. GetDataStreamMappingsAction.java - Added logic to strip _doc wrapper in DataStreamMappingsResponse.toXContent() method
  3. UpdateDataStreamMappingsAction.java - Added logic to strip _doc wrapper in DataStreamMappingsResponse.toXContent() method
  4. 80_ingest_simulate.yml - Updated YAML REST test to expect mappings without _doc wrapper

Implementation Details:

The fix checks if the mapping contains only a single _doc key and unwraps it if present:

if (mapping.size() == 1 && mapping.containsKey(MapperService.SINGLE_MAPPING_NAME)) {
    @SuppressWarnings("unchecked")
    Map<String, Object> unwrapped = (Map<String, Object>) mapping.get(MapperService.SINGLE_MAPPING_NAME);
    builder.field("effective_mapping", unwrapped);
} else {
    builder.field("effective_mapping", mapping);
}

Testing:

  • ✅ All unit tests pass: SimulateIndexResponseTests, GetDataStreamMappingsActionTests, UpdateDataStreamMappingsActionResponseTests
  • ✅ YAML REST test updated and passing: 80_ingest_simulate.yml

Related

The effective_mapping field in the get data stream API response and
simulate ingest API response was incorrectly including a _doc wrapper
at the top level. This fix strips the _doc type placeholder from the
effective mapping output to match the API specification.

Changes:
- SimulateIndexResponse: Strip _doc wrapper in innerToXContent()
- GetDataStreamMappingsAction: Strip _doc wrapper in DataStreamMappingsResponse.toXContent()
- UpdateDataStreamMappingsAction: Strip _doc wrapper in DataStreamMappingsResponse.toXContent()
- Updated YAML REST test to expect mappings without _doc wrapper

The fix uses the same pattern as Template.reduceMapping() to check if
the mapping contains only a single _doc key and unwraps it if present.

Fixes issue where effective_mapping output had incorrect structure.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

0 participants