Fix dynamic_templates merge in legacy index templates#21517
Fix dynamic_templates merge in legacy index templates#21517Harshavardhan2951 wants to merge 1 commit intoopensearch-project:mainfrom
Conversation
Dynamic templates from multiple legacy index templates were being overwritten instead of merged when creating an index. Added special handling in mergeTemplateFieldMappings to combine dynamic_templates lists instead of overwriting. Fixes opensearch-project#21430 Signed-off-by: Harshavardhan2951 <harshavardhan200101@gmail.com>
PR Reviewer Guide 🔍Here are some key observations to aid the review process:
|
PR Code Suggestions ✨Explore these optional code suggestions:
|
|
❌ Gradle check result for 2dc9cf0: FAILURE Please examine the workflow log, locate, and copy-paste the failure(s) below, then iterate to green. Is the failure a flaky test unrelated to your change? |
Description
Fixes
dynamic_templatesmerge regression in legacy index templates.Issues Resolved
Fixes #21430
Problem
When multiple legacy index templates (
_templateAPI) matching thesame index pattern each define
dynamic_templates, only one template'sdynamic_templates survive in the final mapping. The others are
silently lost. This worked correctly in 2.19.0 but regressed in 3.x.
Root Cause
In
MetadataCreateIndexService.mergeTemplateFieldMappings(), therewas no special handling for the
dynamic_templateskey which holdsa List. When the target map already contained
dynamic_templates,the source list was silently ignored.
Fix
Added explicit handling to combine both lists instead of ignoring
the source list.
Testing
testValidateDynamicTemplatesMergeChecklist
is made under the terms of the Apache 2.0 license.
For more information on following Developer Certificate of Origin
and signing off your commits, please check
here.