[9.1] fix: dynamic template vector array is overridden by automatic dense_vector mapping (#143733)#145698
Closed
salvatore-campagna wants to merge 1 commit intoelastic:9.1from
Closed
Conversation
…ense_vector mapping (elastic#143733) Backport of elastic#143733 to 9.1.
Collaborator
|
Pinging @elastic/es-storage-engine (Team:StorageEngine) |
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.
Backport Note
This is a backport of #143733 to 9.1, identical to the 8.19 backport in #143985.
This backport is needed because the rest-compatibility CI check (
yamlRestCompatTest) on the 9.1 branch fails for any PR due to the missing fix. Specifically, the testsearch.vectors/60_dense_vector_dynamic_mapping/Float arrays inside nested objects respect float dynamic templates and are not mapped as dense_vectorwas added upstream but the underlying bug fix was never backported to 9.1, causing arest-compatibilityCI failure (e.g., see #144765).Problem
When a float array is inside a nested object (e.g.,
my_object.my_float_field) and a dynamic template matches that field name (e.g.,match: "*float*"withtype: float), the dynamic template is not respected. Instead, the array is automatically mapped asdense_vector.The root cause is in
DynamicFieldsBuilder.createDynamicField():markFieldAsAppliedFromTemplate(name)uses the short field name (my_float_field), but the automatic dense_vector mapping check uses the full path (my_object.my_float_field). Since they don't match, the "applied from template" marker is missed and the array gets auto-mapped asdense_vector.Fix
Use
context.path().pathAsText(name)instead ofnamewhen callingmarkFieldAsAppliedFromTemplate, so the full field path is stored and correctly matched during the dense_vector auto-detection check.Tests
Float arrays inside nested objects respect float dynamic templates and are not mapped as dense_vectorgated behind themapper.dense_vector.dynamic_template_nested_object_fixcluster feature.