-
Notifications
You must be signed in to change notification settings - Fork 25.2k
Add isFieldMapped method to QueryShardContext #63322
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
Add isFieldMapped method to QueryShardContext #63322
Conversation
As part of elastic#63239 we have moved some usages of `QueryShardContext#getMapperService` that were looking up a field type through the `fieldType` method, to use the existing `QueryShardContext#fieldMapper`. The latter though has additional handling for unmapped fields when the functionality is enabled, and may throw exception if the field is not mapped. This additional behaviour is not desirable and may cause issues in cases where the callers have their own specific handling for situations where the field is not mapped. To address this we introduce an additional fieldType method to `QueryShardContext` that allows to simply look up a field type given its name. relates to elastic#63239
Pinging @elastic/es-search (:Search/Mapping) |
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
@@ -231,6 +231,10 @@ public MappedFieldType fieldMapper(String name) { | |||
return failIfFieldMappingNotFound(name, mapperService.fieldType(name)); | |||
} | |||
|
|||
public MappedFieldType fieldType(String name) { |
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.
Can we put some javadocs on here, specifically around the fact that it may return 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.
Too fast! Can you add a note about null
?
@@ -90,10 +90,6 @@ public Status needsField(FieldInfo fieldInfo) { | |||
public final void postProcess(Function<String, MappedFieldType> fieldTypeLookup) { | |||
for (Map.Entry<String, List<Object>> entry : fields().entrySet()) { | |||
MappedFieldType fieldType = fieldTypeLookup.apply(entry.getKey()); | |||
if (fieldType == 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.
I moved this logic to the caller, it is now part of the lookup function that is provided.
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.
Much nicer, thanks @javanna
As part of elastic#63239 we have moved some usages of QueryShardContext#getMapperService that were looking up a field type through the fieldType method, to use the existing QueryShardContext#fieldMapper. The latter though has additional handling for unmapped fields when the functionality is enabled, and may throw exception if the field is not mapped. This additional behaviour is not desirable and may cause issues in cases where the callers have their own specific handling for situations where the field is not mapped. To address this we introduce an additional isFieldMapped method to QueryShardContext that allows to check if a field is mapped or not. relates to elastic#63239
As part of #63239 we have moved some usages of QueryShardContext#getMapperService that were looking up a field type through the fieldType method, to use the existing QueryShardContext#fieldMapper. The latter though has additional handling for unmapped fields when the functionality is enabled, and may throw exception if the field is not mapped. This additional behaviour is not desirable and may cause issues in cases where the callers have their own specific handling for situations where the field is not mapped. To address this we introduce an additional isFieldMapped method to QueryShardContext that allows to check if a field is mapped or not. relates to #63239
As part of #63239 we have moved some usages of
QueryShardContext#getMapperService
that were looking up a field type through thefieldType
method, to use the existingQueryShardContext#fieldMapper
. The latter though has additional handling for unmapped fields when the functionality is enabled, and may throw exception if the field is not mapped. This additional behaviour is not desirable and may cause issues in cases where the callers have their own specific handling for situations where the field is not mapped.To address this we introduce an additional
isFieldMapped
method toQueryShardContext
that allows to check if a field is mapped or not.relates to #63239