Skip to content
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

Closed
wants to merge 21 commits into from

Conversation

ywelsch
Copy link
Contributor

@ywelsch ywelsch commented Jul 12, 2022

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

@ywelsch ywelsch added :Search Foundations/Mapping Index mappings, including merging and defining field types >non-issue labels Jul 12, 2022
@ywelsch ywelsch marked this pull request as ready for review July 12, 2022 15:52
@elasticmachine elasticmachine added the Team:Search Meta label for search team label Jul 12, 2022
@elasticmachine
Copy link
Collaborator

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) {
Copy link
Contributor Author

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);
Copy link
Contributor Author

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();
Copy link
Contributor Author

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

@javanna javanna removed their request for review July 13, 2022 10:14
Copy link
Contributor

@romseygeek romseygeek left a 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 {
Copy link
Contributor

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?

@elasticsearchmachine elasticsearchmachine changed the base branch from master to main July 22, 2022 23:05
@mark-vieira mark-vieira added v8.5.0 and removed v8.4.0 labels Jul 27, 2022
@csoulios csoulios added v8.6.0 and removed v8.5.0 labels Sep 21, 2022
@kingherc kingherc added v8.7.0 and removed v8.6.0 labels Nov 16, 2022
@javanna
Copy link
Member

javanna commented Nov 30, 2022

We did not go ahead with this change, see #86440 (comment) .

@javanna javanna closed this Nov 30, 2022
@javanna javanna removed the v8.7.0 label Dec 14, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
>non-issue :Search Foundations/Mapping Index mappings, including merging and defining field types Team:Search Meta label for search team
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants