Skip to content

Remove QueryShardContext#getMapperService #63998

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

Merged

Conversation

javanna
Copy link
Member

@javanna javanna commented Oct 21, 2020

We have been removing usages of getMapperService with the purpose of removing the method at some point. This is so we don't have to expose the entire MapperService to all of the users of QueryShardContext, but rather only specific methods so we can better control its usages, especially around resolving field types.

This commit removes the last few usages and adds the missing methods to QueryShardContext. They all revolve around retrieving DocumentMapper from MapperService, yet we can expose specific methods without even exposing DocumentMapper, which would also cause issues.

We have been removing usages of getMapperService with the purpose of removing the method at some point. This is so we don't have to expose the entire MapperService to all of the users of QueryShardContext, but rather only specific methods so we can better control its usages, especially around resolving field types.

This commit removes the last few usages and adds the missing methods to QueryShardContext. They all revolve around retrieving DocumentMapper from MapperService, yet we can expose specific methods without even exposing DocumentMapper, which would also cause issues.
@javanna javanna added :Search Foundations/Mapping Index mappings, including merging and defining field types >refactoring v8.0.0 v7.11.0 labels Oct 21, 2020
@javanna javanna requested a review from romseygeek October 21, 2020 12:41
@elasticmachine
Copy link
Collaborator

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

@elasticmachine elasticmachine added the Team:Search Meta label for search team label Oct 21, 2020

public boolean hasMappings() {
return mapperService.documentMapper() != null;
}
Copy link
Contributor

Choose a reason for hiding this comment

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

This is only used for the RandomScoreFunctionBuilder, correct? Do we need to add it, or can we just remove that 'no mappings' special case?

Copy link
Member Author

Choose a reason for hiding this comment

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

yes that is surprisingly the only usage. but I don't feel comfortable removing that no mappings special case. I think it's legit, although annoying to support, and we test it.

Copy link
Member Author

Choose a reason for hiding this comment

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

@romseygeek are you ok with this or maybe do you have other ideas?

Copy link
Contributor

Choose a reason for hiding this comment

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

Let's leave it in for now, if we decide to go with a no-op mapper by default in MapperService we can remove it then.

Copy link
Member Author

Choose a reason for hiding this comment

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

true, I will try that idea very soon.

@javanna
Copy link
Member Author

javanna commented Oct 21, 2020

run elasticsearch-ci/1

Copy link
Member

@nik9000 nik9000 left a comment

Choose a reason for hiding this comment

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

Awesome!

@javanna javanna merged commit 3efcc55 into elastic:master Oct 22, 2020
javanna added a commit to javanna/elasticsearch that referenced this pull request Oct 22, 2020
We have been removing usages of getMapperService with the purpose of removing the method at some point. This is so we don't have to expose the entire MapperService to all of the users of QueryShardContext, but rather only specific methods so we can better control its usages, especially around resolving field types.

This commit removes the last few usages and adds the missing methods to QueryShardContext. They all revolve around retrieving DocumentMapper from MapperService, yet we can expose specific methods without even exposing DocumentMapper, which would also cause issues.
javanna added a commit that referenced this pull request Oct 22, 2020
We have been removing usages of getMapperService with the purpose of removing the method at some point. This is so we don't have to expose the entire MapperService to all of the users of QueryShardContext, but rather only specific methods so we can better control its usages, especially around resolving field types.

This commit removes the last few usages and adds the missing methods to QueryShardContext. They all revolve around retrieving DocumentMapper from MapperService, yet we can expose specific methods without even exposing DocumentMapper, which would also cause issues.
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 Team:Search Meta label for search team v7.11.0 v8.0.0-alpha1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants