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 Mapper.updateFieldType() #57151

Merged
merged 4 commits into from
May 27, 2020

Conversation

romseygeek
Copy link
Contributor

@romseygeek romseygeek commented May 26, 2020

When we had multiple mapping types, an update to a field in one type had to be
propagated to the same field in all other types. This was done using the
Mapper.updateFieldType() method, called at the end of a merge. However, now
that we only have a single type per index, this method is unnecessary and can
be removed.

Relates to #41059
Backport of #56986

When we had multiple mapping types, an update to a field in one type had to be
propagated to the same field in all other types. This was done using the
Mapper.updateFieldType() method, called at the end of a merge. However, now
that we only have a single type per index, this method is unnecessary and can
be removed.

Relates to elastic#41059
@romseygeek romseygeek added :Search Foundations/Mapping Index mappings, including merging and defining field types >refactoring backport v7.9.0 labels May 26, 2020
@romseygeek romseygeek self-assigned this May 26, 2020
@elasticmachine
Copy link
Collaborator

Pinging @elastic/es-search (:Search/Mapping)

@elasticmachine elasticmachine added the Team:Search Meta label for search team label May 26, 2020
@romseygeek
Copy link
Contributor Author

This is a backport commit for #56986 - there were some test failures on the plain backport, so I've opened a PR to let CI make sure everything works.

@@ -436,106 +436,6 @@ public void testComplexArray() throws Exception {
.endObject().endObject().endObject()), serialize(update));
}

public void testReuseExistingMappings() throws IOException, Exception {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This was testing dead code - we would never update a mapping against a separate type, because the update mappings code already ensures that all updates use the same type name.

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 match what we have on master (it's easier to reason about, and makes backport conflicts less likely). On master we've modified the test to focus on a single type -- we could apply the same change here.

@romseygeek romseygeek changed the title Remove Mapper.updateFieldType() (#56986) Remove Mapper.updateFieldType() May 26, 2020
@romseygeek romseygeek requested a review from jtibshirani May 26, 2020 16:59
@@ -559,29 +547,16 @@ static void validateTypeName(String type) {
}
if (newMapper != null) {
this.mapper = newMapper;
this.fieldTypes = fieldTypes;
Copy link
Contributor

Choose a reason for hiding this comment

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

Same question here about whether this change is important.

}

// make structures immutable
results = Collections.unmodifiableMap(results);
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm wondering if this change is important, where we no longer wrap in an unmodifiable map. If not we could restore it to make the PR more targeted/ precise.

@@ -436,106 +436,6 @@ public void testComplexArray() throws Exception {
.endObject().endObject().endObject()), serialize(update));
}

public void testReuseExistingMappings() throws IOException, Exception {
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 match what we have on master (it's easier to reason about, and makes backport conflicts less likely). On master we've modified the test to focus on a single type -- we could apply the same change here.

@romseygeek romseygeek merged commit d6b79bc into elastic:7.x May 27, 2020
@romseygeek
Copy link
Contributor Author

Thanks @jtibshirani!

@romseygeek romseygeek deleted the mapper/updatefieldtype-7x branch May 27, 2020 08:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
backport >refactoring :Search Foundations/Mapping Index mappings, including merging and defining field types Team:Search Meta label for search team v7.9.0
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants