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

Backport: Add validation for dynamic templates #52890

Merged
merged 2 commits into from
Feb 28, 2020

Conversation

martijnvg
Copy link
Member

Backport of #51233 to 7 dot x branch.

Tries to load a Mapper instance for the mapping snippet of a dynamic template.
This should catch things like using an analyzer that is undefined or mapping attributes that are unused.

This is best effort:

  • If {{name}} placeholder is used in the mapping snippet then validation is skipped.
  • If match_mapping_type is not specified then validation is performed for all mapping types.
    If parsing succeeds with a single mapping type then this the dynamic mapping is considered valid.

If is detected that a dynamic template mapping snippet is invalid at mapping update time then the mapping update is failed for indices created on 8.0.0-alpha1 and later. For indices created on prior version a deprecation warning is omitted instead. In 7.x clusters the mapping update will never fail in case of an invalid dynamic template mapping snippet and a deprecation warning will always be omitted.

Closes #17411
Closes #24419

Co-authored-by: Adrien Grand jpountz@gmail.com

Tries to load a `Mapper` instance for the mapping snippet of a dynamic template.
This should catch things like using an analyzer that is undefined or mapping attributes that are unused.

This is best effort:
* If `{{name}}` placeholder is used in the mapping snippet then validation is skipped.
* If `match_mapping_type` is not specified then validation is performed for all mapping types.
  If parsing succeeds with a single mapping type then this the dynamic mapping is considered valid.

If is detected that a dynamic template mapping snippet is invalid at mapping update time then the mapping update is failed for indices created on 8.0.0-alpha1 and later. For indices created on prior version a deprecation warning is omitted instead. In 7.x clusters the mapping update will never fail in case of an invalid dynamic template mapping snippet and a deprecation warning will always be omitted.

Closes elastic#17411
Closes elastic#24419

Co-authored-by: Adrien Grand <jpountz@gmail.com>
@martijnvg martijnvg added :Search Foundations/Mapping Index mappings, including merging and defining field types :Data Management/Indices APIs APIs to create and manage indices and templates backport v7.7.0 labels Feb 27, 2020
@elasticmachine
Copy link
Collaborator

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

@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-search (:Search/Mapping)

@martijnvg
Copy link
Member Author

@elasticmachine run elasticsearch-ci/packaging-sample-matrix-unix

@martijnvg martijnvg merged commit 6aa9aaa into elastic:7.x Feb 28, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport :Data Management/Indices APIs APIs to create and manage indices and templates :Search Foundations/Mapping Index mappings, including merging and defining field types v7.7.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants