-
Notifications
You must be signed in to change notification settings - Fork 25k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Sketch out recursive merging for template mappings. #57393
Closed
Closed
Conversation
This file contains 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
jtibshirani
commented
May 30, 2020
assert mergeIntoMapper instanceof FieldMapper || mergeIntoMapper instanceof FieldAliasMapper; | ||
// If we're merging template mappings when creating an index, then a field definition always | ||
// replaces an existing one. | ||
if (reason == MergeReason.INDEX_TEMPLATE) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is the most interesting part, we decide to overwrite leaf fields instead of merging them.
We've decided to go with this approach. I'm closing out this draft and will open a new PR for review. |
dakrone
added a commit
to dakrone/elasticsearch
that referenced
this pull request
Jun 4, 2020
This commit changes the merge strategy introduced in elastic#55607 and elastic#55982. Instead of overwriting these fields, we now prevent them from being merged with an exception when a user attempts to overwrite a field. As part of this, a more robust validation has been added. The existing validation checked whether templates (composable and component) were valid on their own, this new validation now checks that the composite template (mappings/settings/aliases) is valid. This means that when a composable template is added or updated, we confirm that it is valid with its component pieces. When a component template is updated we ensure that all composable templates that make use of the component template continue to be valid before allowing the component template to be updated. This change also necessitated changes in the tests, however, I have left tests that exercise mapping merging with nested object fields as `@AwaitsFix`, as we intend to change the behavior soon to allow merging in a recursive-with-replacement fashion (see: elastic#57393). I have added tests that check the new disallowing behavior in the meantime.
dakrone
added a commit
that referenced
this pull request
Jun 8, 2020
) * Disallow merging existing mapping field definitions in templates This commit changes the merge strategy introduced in #55607 and #55982. Instead of overwriting these fields, we now prevent them from being merged with an exception when a user attempts to overwrite a field. As part of this, a more robust validation has been added. The existing validation checked whether templates (composable and component) were valid on their own, this new validation now checks that the composite template (mappings/settings/aliases) is valid. This means that when a composable template is added or updated, we confirm that it is valid with its component pieces. When a component template is updated we ensure that all composable templates that make use of the component template continue to be valid before allowing the component template to be updated. This change also necessitated changes in the tests, however, I have left tests that exercise mapping merging with nested object fields as `@AwaitsFix`, as we intend to change the behavior soon to allow merging in a recursive-with-replacement fashion (see: #57393). I have added tests that check the new disallowing behavior in the meantime. * Use functional instead of imperative prefix collection * Use IndexService.withTempIndexService * Rename tests * Fix tests Co-authored-by: Elastic Machine <[email protected]>
dakrone
added a commit
to dakrone/elasticsearch
that referenced
this pull request
Jun 8, 2020
…stic#57701) * Disallow merging existing mapping field definitions in templates This commit changes the merge strategy introduced in elastic#55607 and elastic#55982. Instead of overwriting these fields, we now prevent them from being merged with an exception when a user attempts to overwrite a field. As part of this, a more robust validation has been added. The existing validation checked whether templates (composable and component) were valid on their own, this new validation now checks that the composite template (mappings/settings/aliases) is valid. This means that when a composable template is added or updated, we confirm that it is valid with its component pieces. When a component template is updated we ensure that all composable templates that make use of the component template continue to be valid before allowing the component template to be updated. This change also necessitated changes in the tests, however, I have left tests that exercise mapping merging with nested object fields as `@AwaitsFix`, as we intend to change the behavior soon to allow merging in a recursive-with-replacement fashion (see: elastic#57393). I have added tests that check the new disallowing behavior in the meantime. * Use functional instead of imperative prefix collection * Use IndexService.withTempIndexService * Rename tests * Fix tests Co-authored-by: Elastic Machine <[email protected]>
dakrone
added a commit
to dakrone/elasticsearch
that referenced
this pull request
Jun 8, 2020
…stic#57701) * Disallow merging existing mapping field definitions in templates This commit changes the merge strategy introduced in elastic#55607 and elastic#55982. Instead of overwriting these fields, we now prevent them from being merged with an exception when a user attempts to overwrite a field. As part of this, a more robust validation has been added. The existing validation checked whether templates (composable and component) were valid on their own, this new validation now checks that the composite template (mappings/settings/aliases) is valid. This means that when a composable template is added or updated, we confirm that it is valid with its component pieces. When a component template is updated we ensure that all composable templates that make use of the component template continue to be valid before allowing the component template to be updated. This change also necessitated changes in the tests, however, I have left tests that exercise mapping merging with nested object fields as `@AwaitsFix`, as we intend to change the behavior soon to allow merging in a recursive-with-replacement fashion (see: elastic#57393). I have added tests that check the new disallowing behavior in the meantime. * Use functional instead of imperative prefix collection * Use IndexService.withTempIndexService * Rename tests * Fix tests Co-authored-by: Elastic Machine <[email protected]>
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.
Note: this is just a sketch, and not an actual PR for review.
This is a prototype for how we could support recursive merging for composable template mappings. I wrote this really quickly, we may want to factor things differently (also there are no tests!)
The overall approach:
MapperService#merge
.ObjectMapper
replaces leaf fields instead of merging them.I really liked that this approach unifies all mapping merging under the same set of concepts. Before, we treated composable template mappings as raw maps, and had custom logic for deduplicating dynamic templates and resolving dots in field names.