-
Notifications
You must be signed in to change notification settings - Fork 25.7k
Split RuntimeFieldType from corresponding MappedFieldType #70695
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
Split RuntimeFieldType from corresponding MappedFieldType #70695
Conversation
So far the runtime section supports only leaf field types, hence the internal representation is based on `RuntimeFieldType` that extends directly `MappedFieldType`. This is straightforward but it is limiting for e.g. an alias field that points to another field, or for object fields that are not queryable directly, hence should not be a MappedFieldType, yet their subfields do. This commit makes `RuntimeFieldType` an interface, effectively splitting the definition of a runtime fields as defined and returned in the mappings, from its internal representation in terms of `MappedFieldType`. The existing runtime script field types still extend `MappedFieldType` and now also implements the new interface, which makes the change rather simple.
|
Pinging @elastic/es-search (Team:Search) |
| * A Builder for a ParametrizedFieldMapper | ||
| */ | ||
| public abstract static class Builder extends Mapper.Builder { | ||
| public abstract static class Builder extends Mapper.Builder implements ToXContentFragment { |
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 is not extremely important, at the same time I got frustrated that we were carrying around a CheckedBiConsumer while we have a commonly used interface for this sort of things. This change allows carrying a ToXContent instance instead in the different script field types
| super(name, false, false, false, TextSearchInfo.SIMPLE_MATCH_WITHOUT_TERMS, meta); | ||
| this.toXContent = toXContent; | ||
| } | ||
| public interface RuntimeFieldType extends ToXContentFragment { |
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.
@romseygeek looks familiar? :) I did take inspiration from your previous proposal around aliases as runtime fields.
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 would propose renaming this to RuntimeField in a follow-up
| * Exposes the {@link MappedFieldType} backing this runtime field, used to execute queries, run aggs etc. | ||
| * @return the {@link MappedFieldType} backing this runtime field | ||
| */ | ||
| MappedFieldType asMappedFieldType(); |
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 envision this returning a Collection once we introduce the object runtime field
| MappedFieldType fieldType = runtimeFieldType.asMappedFieldType(); | ||
| runtimeFieldTypes.put(fieldType.name(), fieldType); | ||
| } | ||
| return Collections.unmodifiableMap(runtimeFieldTypes); |
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 was thinking that maybe we should make FieldTypeLookup public and use it in SearchExecutionContext instead of reproducing its behavour with the runtime fields defined in the search request
romseygeek
left a comment
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.
What a great idea, who thought of this? :)
LGTM.
) So far the runtime section supports only leaf field types, hence the internal representation is based on `RuntimeFieldType` that extends directly `MappedFieldType`. This is straightforward but it is limiting for e.g. an alias field that points to another field, or for object fields that are not queryable directly, hence should not be a MappedFieldType, yet their subfields do. This commit makes `RuntimeFieldType` an interface, effectively splitting the definition of a runtime fields as defined and returned in the mappings, from its internal representation in terms of `MappedFieldType`. The existing runtime script field types still extend `MappedFieldType` and now also implement the new interface, which makes the change rather simple.
…70715) So far the runtime section supports only leaf field types, hence the internal representation is based on `RuntimeFieldType` that extends directly `MappedFieldType`. This is straightforward but it is limiting for e.g. an alias field that points to another field, or for object fields that are not queryable directly, hence should not be a MappedFieldType, yet their subfields do. This commit makes `RuntimeFieldType` an interface, effectively splitting the definition of a runtime fields as defined and returned in the mappings, from its internal representation in terms of `MappedFieldType`. The existing runtime script field types still extend `MappedFieldType` and now also implement the new interface, which makes the change rather simple.
So far the runtime section supports only leaf field types, hence the internal representation is based on
RuntimeFieldTypethat extends directlyMappedFieldType. This is straightforward but it is limiting for e.g. an alias field that points to another field, or for object fields that are not queryable directly, hence should not be a MappedFieldType, yet their subfields do.This commit makes
RuntimeFieldTypean interface, effectively splitting the definition of a runtime fields as defined and returned in the mappings, from its internal representation in terms ofMappedFieldType.The existing runtime script field types still extend
MappedFieldTypeand now also implements the new interface, which makes the change rather simple.