-
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
Merged
romseygeek
merged 4 commits into
elastic:master
from
romseygeek:types-removal/update-mapping-type-check
Oct 3, 2019
Merged
Changes from 2 commits
Commits
Show all changes
4 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -70,7 +70,6 @@ | |
import java.util.LinkedHashMap; | ||
import java.util.List; | ||
import java.util.Map; | ||
import java.util.Objects; | ||
import java.util.Set; | ||
import java.util.function.Function; | ||
import java.util.function.Supplier; | ||
|
@@ -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 commentThe reason will be displayed to describe this comment to others. Learn more. It would be good to remove |
||
return internalMerge(Collections.singletonMap(type, mappingSource), reason).get(type); | ||
// TODO change internalMerge() to return a single DocumentMapper rather than a Map | ||
return internalMerge(Collections.singletonMap(type, mappingSource), reason).values().iterator().next(); | ||
} | ||
|
||
private synchronized Map<String, DocumentMapper> internalMerge(IndexMetaData indexMetaData, | ||
|
@@ -373,14 +373,6 @@ private synchronized Map<String, DocumentMapper> internalMerge(DocumentMapper ma | |
|
||
Map<String, DocumentMapper> results = new LinkedHashMap<>(2); | ||
|
||
{ | ||
if (mapper != null && this.mapper != null && Objects.equals(this.mapper.type(), mapper.type()) == false) { | ||
throw new IllegalArgumentException( | ||
"Rejecting mapping update to [" + index().getName() + "] as the final mapping would have more than 1 type: " | ||
+ Arrays.asList(this.mapper.type(), mapper.type())); | ||
} | ||
} | ||
|
||
DocumentMapper newMapper = null; | ||
if (mapper != null) { | ||
// check naming | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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:my_type
._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.