Skip to content
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

Handle merging dotted object names when merging V2 template mappings #55982

Merged
merged 2 commits into from
Apr 30, 2020

Conversation

dakrone
Copy link
Member

@dakrone dakrone commented Apr 29, 2020

When merging component template, index template, and request mappings, we now treat any declaration
of a top-level field the same as replacing all sub-objects. For example, assuming two component
templates with mappings and template B taking precedence:

A: {foo: {...}}
B: {foo.bar: {...}}
Result: {foo.bar: {...}}

A: {foo.bar: {...}}
B: {foo: {...}}
Result: {foo: {...}}

A: {foo.bar: {...}}
B: {foo.baz: {...}}
Result: {foo.baz: {...}}

Relates to #53101

When merging component template, index template, and request mappings, we now treat any declaration
of a top-level field the same as replacing all sub-objects. For example, assuming two component
templates with mappings and template B taking precedence:

```
A: {foo: {...}}
B: {foo.bar: {...}}
Result: {foo.bar: {...}}

A: {foo.bar: {...}}
B: {foo: {...}}
Result: {foo: {...}}

A: {foo.bar: {...}}
B: {foo.baz: {...}}
Result: {foo.baz: {...}}
```

Relates to elastic#53101
@dakrone dakrone added :Data Management/Indices APIs APIs to create and manage indices and templates v8.0.0 v7.8.0 labels Apr 29, 2020
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-core-features (:Core/Features/Indices APIs)

@elasticmachine elasticmachine added the Team:Data Management Meta label for data/management team label Apr 29, 2020
@martijnvg martijnvg mentioned this pull request Apr 29, 2020
39 tasks
@dakrone dakrone requested a review from probakowski April 30, 2020 14:30
Copy link
Contributor

@probakowski probakowski left a comment

Choose a reason for hiding this comment

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

LGTM 👍 thanks @dakrone!

@dakrone dakrone merged commit 89b538f into elastic:master Apr 30, 2020
@dakrone dakrone deleted the itv2-merge-object-mappings branch April 30, 2020 15:12
dakrone added a commit to dakrone/elasticsearch that referenced this pull request Apr 30, 2020
…lastic#55982)

When merging component template, index template, and request mappings, we now treat any declaration
of a top-level field the same as replacing all sub-objects. For example, assuming two component
templates with mappings and template B taking precedence:

```
A: {foo: {...}}
B: {foo.bar: {...}}
Result: {foo.bar: {...}}

A: {foo.bar: {...}}
B: {foo: {...}}
Result: {foo: {...}}

A: {foo.bar: {...}}
B: {foo.baz: {...}}
Result: {foo.baz: {...}}
```

Relates to elastic#53101
dakrone added a commit that referenced this pull request Apr 30, 2020
…pings (#55982) (#56041)

Backports the following commits to 7.x:
 - Handle merging dotted object names when merging V2 template mappings (#55982)
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
Labels
:Data Management/Indices APIs APIs to create and manage indices and templates >enhancement Team:Data Management Meta label for data/management team v7.8.0 v8.0.0-alpha1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants