-
Notifications
You must be signed in to change notification settings - Fork 25.2k
Move MappedFieldType.similarity() to TextSearchInfo #58439
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
Conversation
Pinging @elastic/es-search (:Search/Mapping) |
} | ||
// TODO should we allow to configure the prefix field | ||
} | ||
parseTextField(builder, name, node, parserContext); |
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.
The shared parseTextField()
method does a deprecation check for similarity
now, so we need to move it to after we've processed the similarity
field. To ensure that mapper-specific fields still get checked for null
, a new TypeParsers.checkNull()
method is called for each entry.
} | ||
} | ||
parseTextField(builder, fieldName, node, parserContext); |
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.
Same process here as in SearchAsYouTypeFieldMapper
new Modifier("similarity", false, (a, b) -> { | ||
a.similarity(new SimilarityProvider("BM25", new BM25Similarity())); | ||
b.similarity(new SimilarityProvider("boolean", new BooleanSimilarity())); | ||
}), |
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 has been moved directly into the applicable FieldMappers
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.
LGTM
Similarities only apply to a few text-based field types, but are currently set directly on the base MappedFieldType class. This commit moves similarity information into TextSearchInfo, and removes any mentions of it from MappedFieldType or FieldMapper. It was previously possible to include a similarity parameter on a number of field types that would then ignore this information. To make it obvious that this has no effect, setting this parameter on non-text field types now issues a deprecation warning.
@@ -163,7 +163,8 @@ Similarity getDefaultSimilarity() { | |||
@Override | |||
public Similarity get(String name) { | |||
MappedFieldType fieldType = mapperService.fieldType(name); | |||
return (fieldType != null && fieldType.similarity() != null) ? fieldType.similarity().get() : defaultSimilarity; | |||
return (fieldType != null && fieldType.getTextSearchInfo().getSimilarity() != null) |
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.
would it be possible to avoid having null similarity provider in TextSearchInfo and rather pass in directly the default similarity, or have some placeholder instead of null?
Similarities only apply to a few text-based field types, but are currently set directly on
the base MappedFieldType class. This commit moves similarity information into
TextSearchInfo, and removes any mentions of it from MappedFieldType or FieldMapper.
It was previously possible to include a
similarity
parameter on a number of field typesthat would then ignore this information. To make it obvious that this has no effect, setting
this parameter on non-text field types now issues a deprecation warning.