-
Notifications
You must be signed in to change notification settings - Fork 24.9k
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
Remove typename checks in mapping updates #47347
Conversation
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); |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
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.
There was a problem hiding this 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) { |
There was a problem hiding this comment.
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.
@elasticmachine update branch |
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