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

Add migration tool checks for _field_names disabling #46972

Merged

Conversation

cbuescher
Copy link
Member

This change adds a check to the migration tool that warns about the deprecated
"enabled" setting for the "_field_names" field on 7.x indices and issues a
critical error for templates containing this setting, since it has been removed
with 8.0.

Relates to #42854, #46681

@cbuescher cbuescher added :Search Foundations/Mapping Index mappings, including merging and defining field types v7.5.0 labels Sep 23, 2019
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-search

@cbuescher
Copy link
Member Author

@jtibshirani since you already reviewed #46681 that adds throwing an error on 8.0 for this setting, maybe you can also take a look at this PR that adds checks for existing mappings and templates to the migration assistant?

This change adds a check to the migration tool that warns about the deprecated
"enabled" setting for the "_field_names" field on 7.x indices and issues a
critical error for templates containing this setting, since it has been removed
with 8.0.

Relates to elastic#42854, elastic#46681
@cbuescher cbuescher force-pushed the fieldnames_disabling_deprecationcheck branch from e894414 to b3e5098 Compare September 23, 2019 12:18
Copy link
Contributor

@jtibshirani jtibshirani left a comment

Choose a reason for hiding this comment

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

I left a couple comments. Thanks for adding these helpful checks.

/**
* check for "_field_names" entries in the map that contain another property "enabled" in the sub-map
*/
static boolean mapContainsFieldNamesDisabled(Map<?, ?> map) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Do we need to use a recursive function here, or could we just check for it directly since we know _field_names will be at the top level of the mapping? Also, there is a convenient method IndexDeprecationChecks#findInPropertiesRecursively for iterating over a mapping.

Copy link
Member Author

Choose a reason for hiding this comment

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

I opted for the recursive function just to make sure we catch all type-vs-no-type cases (see also the test cases). If we always have (or don't have) a type-level in the internally stored mappings in the templates, then we can probably do without but I wanted to check with you on this, it wasn't completely clear to me from reading the code. The mapping maps are quite forgiving for what you store in them, so it depends on the caller and I didn't completely follow the internal logic.

there is a convenient method IndexDeprecationChecks#findInPropertiesRecursively

I saw and tried to use this, but ran into problems because it assumes things are stored under a properties key which I think the "_field_nams" : { "enabled" : ...} is not (correct me if I'm wrong).

Let me if you know for sure how the internal map structure is supposed to look like (at which level to expect the "_field_names" key) and I can update the tests accordingly and try making this non-recursive.

Copy link
Contributor

Choose a reason for hiding this comment

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

I saw and tried to use this, but ran into problems because it assumes things are stored under a properties key

Ah, I missed this -- then findInPropertiesRecursively is indeed not a good fit.

Let me if you know for sure how the internal map structure is supposed to look like

I left some comments on your individual questions, let me know if anything is still unclear!

@cbuescher
Copy link
Member Author

cbuescher commented Sep 24, 2019

@jtibshirani I verified my assumptions about what the mappings/templates maps really contain in a local cluster with and without explicit type definitions a bit further and added 67e44ae as another commit. I will add a few remarks / questions where I'm unsure my understanding is correct, maybe you can verify those.

@cbuescher
Copy link
Member Author

@elasticmachine run elasticsearch-ci/default-distro

@cbuescher
Copy link
Member Author

Thanks for the comments, I hope f00a419 solves the edge case you mentioned.

Copy link
Contributor

@jtibshirani jtibshirani left a comment

Choose a reason for hiding this comment

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

Looks good to me.

@cbuescher
Copy link
Member Author

@elasticmachine run elasticsearch-ci/default-distro

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>enhancement :Search Foundations/Mapping Index mappings, including merging and defining field types v7.5.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants