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

Remove default mapping #44945

Merged
merged 7 commits into from
Sep 20, 2019
Merged

Remove default mapping #44945

merged 7 commits into from
Sep 20, 2019

Conversation

romseygeek
Copy link
Contributor

Default mappings cannot be created in 7x indexes, so we no longer need to keep
support for them in master.

@romseygeek romseygeek added :Search Foundations/Mapping Index mappings, including merging and defining field types >refactoring v8.0.0 labels Jul 29, 2019
@romseygeek romseygeek self-assigned this Jul 29, 2019
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-search

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.

Thanks @romseygeek, this is looking good to me! I spotted one other reference to _default_ here: https://github.com/elastic/elasticsearch/blob/master/server/src/main/java/org/elasticsearch/action/admin/indices/mapping/get/GetMappingsResponse.java#L126

To check I'm on the same page with the upgrade plan, this is my understanding of what we will recommend to users upgrading from 7.x -> 8.x:

  • There may be some indices created in 6.x that still contain default mappings. However, these will need to be reindexed before upgrading to 8.x, so we don't need any special logic to handle these mappings during the upgrade.
  • If there are any index templates from 6.x that haven't been updated, users should make sure to re-add them with no default mapping (and no type).

@@ -727,8 +724,7 @@ static IndexMetaData validateResize(ClusterState state, String sourceIndex,
throw new IllegalStateException("index " + sourceIndex + " must be read-only to resize index. use \"index.blocks.write=true\"");
}

if ((targetIndexMappingsTypes.size() > 1 ||
(targetIndexMappingsTypes.isEmpty() || targetIndexMappingsTypes.contains(MapperService.DEFAULT_MAPPING)) == false)) {
if ((targetIndexMappingsTypes.size() != 0)) {
Copy link
Contributor

Choose a reason for hiding this comment

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

Minor comment: extra parentheses here, and could be targetIndexMappingsTypes.size() > 0.

// first, simulate: just call merge and ignore the result
existingMapper.merge(newMapper.mapping());
}
newMapper = mapperService.parse(request.type(), mappingUpdateSource);
Copy link
Contributor

Choose a reason for hiding this comment

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

This could be combined with the declaration: DocumentMapper newMapper = ...

if (mappings.containsKey(MapperService.DEFAULT_MAPPING)) {
MappingMetaData defaultMapping = mappings.get(MapperService.DEFAULT_MAPPING);
for (ObjectCursor<MappingMetaData> cursor : mappings.values()) {
cursor.value.updateDefaultMapping(defaultMapping);
Copy link
Contributor

Choose a reason for hiding this comment

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

I think we can nuke the updateDefaultMapping method now that this block is deleted.

@romseygeek
Copy link
Contributor Author

Thanks for the review @jtibshirani (and apologies for the gap between updates). I made some updates based on your feedback.

There may be some indices created in 6.x that still contain default mappings. However, these will need to be reindexed before upgrading to 8.x, so we don't need any special logic to handle these mappings during the upgrade.

Right

If there are any index templates from 6.x that haven't been updated, users should make sure to re-add them with no default mapping (and no type).

Yes - I'll check to see if we're emitting deprecation warnings here already

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.

This looks good to me. I see just one more reference to the default mapping that would be good to remove before merging: https://github.com/elastic/elasticsearch/blob/master/server/src/main/java/org/elasticsearch/action/admin/indices/mapping/get/GetMappingsResponse.java#L126

@alpar-t
Copy link
Contributor

alpar-t commented Sep 12, 2019

@elasticmachine test this please

@romseygeek
Copy link
Contributor Author

@elasticmachine please test this

@romseygeek
Copy link
Contributor Author

@elasticmachine test this please

@romseygeek
Copy link
Contributor Author

@elasticmachine update branch

@romseygeek
Copy link
Contributor Author

@elasticmachine update branch

@romseygeek romseygeek merged commit 6a5bae1 into elastic:master Sep 20, 2019
@romseygeek romseygeek deleted the default-mappings branch September 20, 2019 13:26
@jpountz jpountz mentioned this pull request Sep 20, 2019
66 tasks
@pgomulka pgomulka mentioned this pull request Mar 25, 2020
66 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>refactoring :Search Foundations/Mapping Index mappings, including merging and defining field types v8.0.0-alpha1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants