Skip to content

Conversation

@masseyke
Copy link
Member

@masseyke masseyke commented Jul 29, 2025

As reported in #131425, the simulate index API does not account for data stream mapping overrides. It also does not account for data stream setting overrides. Here is how it impacts the simulate APIs:

  • simulate index (_index_template/_simulate_index/{index_name})
    • Does not account for data stream mapping overrides
    • Does not account for data stream setting overrides
  • simulate ingest (_ingest/_simulate)
    • Does not account for data stream mapping overrides
    • Does not account for data stream setting overrides, but they are irrelevant at the moment because you cannot override any setting that would have an impact (this change fixes that, but there is no way to test it)
  • simulate index template (_index_template/_simulate)
    • It uses the method that was fixed, but there is no way to use an existing data stream in this API since it uses a fake index name
  • simulate pipeline (_ingest/pipeline)
    • Not affected since you can't specify an index or data stream

This PR fixes TransportSimulateIndexTemplateAction.resolveTemplate() by reading the data stream for the index (if it exists) in a new ProjectMetadata argument. It adds the data stream's mapping and setting overrides to the template it is creating.

Closes #131425

@elasticsearchmachine
Copy link
Collaborator

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

@masseyke masseyke marked this pull request as ready for review July 30, 2025 19:41
@masseyke masseyke requested a review from dakrone July 30, 2025 19:41
@elasticsearchmachine
Copy link
Collaborator

Pinging @elastic/es-data-management (Team:Data Management)

@elasticsearchmachine elasticsearchmachine added the Team:Data Management Meta label for data/management team label Jul 30, 2025
@elasticsearchmachine
Copy link
Collaborator

Hi @masseyke, I've updated the changelog YAML for you.

@masseyke masseyke requested a review from Copilot August 1, 2025 15:11
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull Request Overview

This PR fixes the simulate index template API to properly account for data stream mapping and setting overrides. The core issue was that when simulating templates for data streams, the API wasn't considering the overrides that had been applied to the data stream, leading to inaccurate simulation results.

Key changes:

  • Modified resolveTemplate() method to accept an additional ProjectMetadata parameter for accessing actual project data
  • Added logic to retrieve and apply data stream mapping and setting overrides when the template is for a data stream
  • Updated all callers of resolveTemplate() to provide the new parameter

Reviewed Changes

Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
TransportSimulateIndexTemplateAction.java Core fix - adds data stream override logic to resolveTemplate() method
TransportSimulateBulkAction.java Updated to pass actual project metadata to resolveTemplate()
TransportSimulateTemplateAction.java Updated to pass project metadata (with explanatory comment)
TransportSimulateIndexTemplateActionTests.java Updated test to provide new parameter
10_basic.yml Added integration test for data stream overrides
80_ingest_simulate.yml Added test for ingest simulation with data stream mapping overrides
132131.yaml Changelog entry for the bug fix

Copy link
Member

@dakrone dakrone left a comment

Choose a reason for hiding this comment

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

LGTM, I left two really minor comments

);
}

private static List<CompressedXContent> collectMappings(
Copy link
Member

Choose a reason for hiding this comment

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

Can you add javadocs for this method?

private static Settings collectSettings(
final ProjectMetadata simulatedProject,
final DataStream dataStream,
String templateNmae,
Copy link
Member

Choose a reason for hiding this comment

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

Minor typo: templateNmae -> templateName

@masseyke masseyke added the auto-backport Automatically create backport pull requests when merged label Aug 11, 2025
@masseyke masseyke merged commit f8b2ed9 into elastic:main Aug 11, 2025
33 checks passed
@masseyke masseyke deleted the fix/TransportSimulateIndexTemplateAction-resolveTemplate branch August 11, 2025 18:50
@elasticsearchmachine
Copy link
Collaborator

💔 Backport failed

Status Branch Result
8.19 Commit could not be cherrypicked due to conflicts
9.1 Commit could not be cherrypicked due to conflicts
9.0 Commit could not be cherrypicked due to conflicts

You can use sqren/backport to manually backport by running backport --upstream elastic/elasticsearch --pr 132131

@masseyke
Copy link
Member Author

Removing the backport labels because data stream settings did not appear until 9.2.0.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

:Data Management/Indices APIs APIs to create and manage indices and templates >non-issue Team:Data Management Meta label for data/management team v9.2.0

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Include data stream level mappings in simulate index

3 participants