-
Notifications
You must be signed in to change notification settings - Fork 24.4k
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
Extract field name from MappedFieldType #88475
Conversation
Pinging @elastic/es-search (Team:Search) |
if (ft instanceof final RankFeatureFieldType fft) { | ||
return scoreFunction.toQuery(RankFeatureMetaFieldMapper.NAME, field, fft.positiveScoreImpact()); | ||
} else if (ft == null) { | ||
if (mappedField == 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 reordered the if/else clauses here to move the null check to the top (as we can't otherwise call mappedField.type()
without a NPE)
boolean isIndexed, | ||
boolean isStored, | ||
boolean hasDocValues, | ||
TextSearchInfo textSearchInfo, | ||
Map<String, String> meta | ||
) { | ||
this.name = Mapper.internFieldName(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.
This has moved to the MappedField class now.
if (context.allowExpensiveQueries() == false) { | ||
throw new ElasticsearchException( | ||
"runtime-computed exists query cannot be executed while [" + ALLOW_EXPENSIVE_QUERIES.getKey() + "] is set to [false]." | ||
); | ||
} | ||
return existQueryFieldType.existsQuery(context); | ||
// norms are not available, neither are doc-values, so fall back to _source to run exists query | ||
final MappedField existQueryField = KeywordScriptFieldType.sourceOnly(name).asMappedFields().findFirst().get(); |
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 was moved from the constructor of LegacyTextFieldType now to the invocation site here, as we need the name
to construct the existQueryField
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. It would be good to have some javadoc on the new FieldMapper class too.
import java.util.function.Function; | ||
import java.util.function.Supplier; | ||
|
||
public class MappedField { |
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 have some javadoc here?
We did not go ahead with this change, see #86440 (comment) . |
Separates the field name from MappedFieldType, making MappedFieldType just a container for type-related information.
The combination of field name and typing information is now available via a new MappedField class.
As follow-up, we would like to implement equals/hashCode on this new name-stripped MappedFieldType, so that we can deduplicate MappedFieldType instances. This should dramatically lower the memory usage of large mappings on data nodes.
Relates #86440