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 typename checks in mapping updates #47347

Merged

Conversation

romseygeek
Copy link
Contributor

This commit removes types validation during mapping updates. This will make
further work on types removal easier, as it will prevent test failures due to type-name
clashes when we remove type information from PutMapping and CreateIndex requests

Part of #41059

@romseygeek romseygeek added >non-issue :Search Foundations/Mapping Index mappings, including merging and defining field types v8.0.0 labels Oct 1, 2019
@romseygeek romseygeek requested a review from colings86 October 1, 2019 10:07
@romseygeek romseygeek self-assigned this Oct 1, 2019
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-search

if (existingMapper != null) {
existingSource = existingMapper.mappingSource();
}
DocumentMapper mergedMapper = mapperService.merge(typeForUpdate, mappingUpdateSource, MergeReason.MAPPING_UPDATE);
DocumentMapper mergedMapper = mapperService.merge(request.type(), mappingUpdateSource, MergeReason.MAPPING_UPDATE);
Copy link
Contributor

@jtibshirani jtibshirani Oct 1, 2019

Choose a reason for hiding this comment

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

Here we no longer use the resolved type typeForUpdate. This type resolution logic allowed for 'put mapping' to work in the following scenario:

  • An index contains a custom type like my_type.
  • The user adds new mappings using a typeless put mapping call (which uses the _doc type under the hood).

We still need to support this case, because there could be indices carried over from 7.x with a custom type name. I think that CI didn't catch the issue because the relevant 'mix typeful and typeless' tests were removed in #41676. Perhaps we could restore some of those tests, and make sure to preserve the necessary logic here.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Type names will be removed entirely for 8x though, so I don't think this issue will arise? The point of this PR is to remove the type resolution checks because we know that an index can only have a single type, so it doesn't matter what it's called. It's a staging commit that means we can remove type information from things like put-mapping or create-index without having to go and change all our tests to use a _doc type, only to then remove the types completely in a follow-up commit.

Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry @romseygeek, I should have done some tests before writing that comment! The scenario I described actually seems to work, because we completely ignore the type on the request. I don't see a bug, and it sounds like we're on the same page with this PR.

I do wonder if could use more tests around the scenario I described, I'll follow-up on #41676 to discuss.

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.

@@ -303,7 +302,8 @@ public void merge(IndexMetaData indexMetaData, MergeReason reason) {
}

public DocumentMapper merge(String type, CompressedXContent mappingSource, MergeReason reason) {
Copy link
Contributor

Choose a reason for hiding this comment

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

It would be good to remove MapperService#getTypeForUpdate, since it is no longer used.

@romseygeek
Copy link
Contributor Author

@elasticmachine update branch

@romseygeek romseygeek merged commit 2946355 into elastic:master Oct 3, 2019
@romseygeek romseygeek deleted the types-removal/update-mapping-type-check branch October 3, 2019 10:25
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>non-issue :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.

4 participants