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

Use ValueFetcher when loading text snippets to highlight #63572

Merged
merged 10 commits into from
Nov 24, 2020
Prev Previous commit
Next Next commit
Merge remote-tracking branch 'origin/master' into highlight/fetcher
  • Loading branch information
romseygeek committed Nov 23, 2020
commit 2ea506de64a10a5bd3c56c126d4204f166a5d086
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ static class TokenCountFieldType extends NumberFieldMapper.NumberFieldType {
}

@Override
public ValueFetcher valueFetcher(QueryShardContext context, SearchLookup searchLookup, String format) {
if (hasDocValues() == false || searchLookup == null) {
public ValueFetcher valueFetcher(QueryShardContext context, String format) {
if (hasDocValues() == false) {
return lookup -> List.of();
}
return new DocValueFetcher(docValueFormat(format, null), context.getForField(this));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,7 @@ public static List<Object> loadFieldValues(MappedFieldType fieldType,
List<Object> textsToHighlight = fieldVisitor.fields().get(fieldType.name());
return Objects.requireNonNullElse(textsToHighlight, Collections.emptyList());
}
ValueFetcher fetcher = fieldType.valueFetcher(qsc, null, null);
ValueFetcher fetcher = fieldType.valueFetcher(qsc, null);
return fetcher.fetchValues(hitContext.sourceLookup());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,6 @@

import java.io.IOException;
import java.time.ZoneId;
import java.util.Collections;
import java.util.List;
import java.util.Locale;
import java.util.Map;
Expand Down Expand Up @@ -198,11 +197,8 @@ protected final void checkAllowExpensiveQueries(QueryShardContext context) {
}

@Override
public ValueFetcher valueFetcher(QueryShardContext context, SearchLookup lookup, String format) {
if (lookup == null) {
return v -> Collections.emptyList();
}
return new DocValueFetcher(docValueFormat(format, null), lookup.doc().getForField(this));
public ValueFetcher valueFetcher(QueryShardContext context, String format) {
return new DocValueFetcher(docValueFormat(format, null), context.getForField(this));
}

@Override
Expand Down
You are viewing a condensed version of this merge commit. You can view the full changes here.