Skip to content

Rework similarities to use lucene's PerFieldSimilarityWrapper on MapperService #57053

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

Closed

Conversation

romseygeek
Copy link
Contributor

Similarity providers for text fields are currently held directly on MappedFieldType,
and accessing them requires both a MapperService and a SimilarityService. This
makes things unnecessarily complicated (for example, Mapper.ParserContext needs
to hold references to both), and clutters the field type interface with
a field that only makes sense for text-based mappers.

This PR refactors things so that the MapperService is responsible for providing a
Similarity for an index, using lucene's PerFieldSimilarityWrapper to make field
configurations possible. Similarities for text fields are collected by visiting all
FieldMappers after a merge, and combining them appropriately.

@romseygeek romseygeek added :Search Foundations/Mapping Index mappings, including merging and defining field types >breaking-java >refactoring v8.0.0 v7.9.0 labels May 21, 2020
@romseygeek romseygeek requested a review from jtibshirani May 21, 2020 17:18
@romseygeek romseygeek self-assigned this May 21, 2020
@elasticmachine
Copy link
Collaborator

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

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

If this works then we should also be able to do the same thing for the index, search and search quote analyzers, further simplifying the MappedFieldType class.

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.

I left one high-level comment, but haven't done a detailed review yet.

@@ -172,6 +161,10 @@ public final String simpleName() {
* Both {@code this} and {@code mergeWith} will be left unmodified. */
public abstract Mapper merge(Mapper mergeWith);

public void collectPerFieldResources(PerFieldResourceCollector collector) {
Copy link
Contributor

Choose a reason for hiding this comment

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

If I'm understanding correctly, it's still possible to set a similarity on a non-text field, but we now ignore it. Although I agree that similarities aren't nearly as useful for non-text fields, this behavior seems trappy and it's technically a breaking change.

My vote would be to maintain the previous behavior where similarities on types like keyword were respected. If we want to disallow setting similarities on non-text types, we could open a dedicated issue to discuss it.

@romseygeek
Copy link
Contributor Author

Superseded by #58439

@romseygeek romseygeek closed this Jun 24, 2020
@romseygeek romseygeek deleted the mapper/shared-similarity branch June 24, 2020 15:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>breaking-java >refactoring :Search Foundations/Mapping Index mappings, including merging and defining field types Team:Search Meta label for search team v7.9.0 v8.0.0-alpha1
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants