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

Add source fallback for keyword fields using operation #88735

Merged
merged 42 commits into from
Jul 28, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
42 commits
Select commit Hold shift + click to select a range
9227535
Update SearchLookup to include source paths for each field.
jdconrad Jun 16, 2022
ad63384
Add source fallback for keyword field.
jdconrad Jun 16, 2022
d110c7d
Update some tests for keyword source fallback.
jdconrad Jun 20, 2022
892b27a
separate script source fallback into its own method
jdconrad Jun 24, 2022
30fc69b
Update docs/changelog/88040.yaml
jdconrad Jun 27, 2022
4c522c4
Merge branch 'master' into sourcefallback
jdconrad Jun 27, 2022
27f7d80
update change log
jdconrad Jun 27, 2022
47e8955
Merge branch 'master' into sourcefallback
jdconrad Jun 27, 2022
d105a93
Merge branch 'master' into sourcefallback
jdconrad Jun 28, 2022
60d4d0e
Delete docs/changelog/88040.yaml
jdconrad Jul 7, 2022
661d2c1
Merge branch 'master' into sourcefallback
jdconrad Jul 11, 2022
1d0ffd1
Merge branch 'master' into sourcefallback
jdconrad Jul 11, 2022
39cde22
fix tests with master merge
jdconrad Jul 11, 2022
0693ac0
add keyword source fallback for scripting using value fetcher
jdconrad Jul 11, 2022
9062de7
replace tuple return with marker interface
jdconrad Jul 12, 2022
c56371e
Merge branch 'master' into sourcefallback
jdconrad Jul 12, 2022
6a3aa33
Merge branch 'master' into sourcefallback
jdconrad Jul 12, 2022
6a03351
Merge branch 'master' into sourcefallback
jdconrad Jul 14, 2022
170b9af
Split off value fetcher index field data into base classes.
jdconrad Jul 14, 2022
50beaea
Add integer field to source fallback w/ value fetcher strategy.
jdconrad Jul 18, 2022
c91f730
Add script source fallback for geopoint field.
jdconrad Jul 18, 2022
a8854c3
Merge branch 'master' into sourcefallback
jdconrad Jul 18, 2022
38df037
Merge branch 'master' into sourcefallback
jdconrad Jul 21, 2022
32d8ace
add fielddatatype
jdconrad Jul 21, 2022
f039525
Fix package
jdconrad Jul 22, 2022
e5de7f3
Merge branch 'master' into sfoptions
jdconrad Jul 22, 2022
e8f813a
change name from type to operation
jdconrad Jul 22, 2022
aa4c75a
Update docs/changelog/88735.yaml
jdconrad Jul 22, 2022
02ee1e3
Delete docs/changelog/88735.yaml
jdconrad Jul 22, 2022
a32bce8
Merge branch 'master' into sfoptions
jdconrad Jul 22, 2022
3debbab
Merge branch 'main' into sfoptions
jdconrad Jul 25, 2022
266b231
Merge branch 'main' into sfoptions
jdconrad Jul 26, 2022
69cd948
Merge branch 'main' into sfoptions
jdconrad Jul 26, 2022
5c11166
Merge branch 'main' into sfoptions
jdconrad Jul 27, 2022
f341afa
add sourceValueFetcher methods for keyword and number field types
jdconrad Jul 27, 2022
4a6efd9
Merge branch 'main' into sfoptions
jdconrad Jul 27, 2022
b5258ad
fix bad merge
jdconrad Jul 27, 2022
d5d83d7
Merge branch 'main' into sfoptions
jdconrad Jul 28, 2022
8055416
response to pr comments
jdconrad Jul 28, 2022
5b41bb2
fix tests
jdconrad Jul 28, 2022
758e2c9
Merge branch 'main' into sfoptions
jdconrad Jul 28, 2022
2dd57a7
Update docs/changelog/88735.yaml
jdconrad Jul 28, 2022
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,7 @@
import java.nio.file.Path;
import java.util.List;
import java.util.Map;
import java.util.Set;
import java.util.concurrent.TimeUnit;

/**
Expand All @@ -83,10 +84,11 @@ public class ScriptScoreBenchmark {
Map.entry("n", new NumberFieldType("n", NumberType.LONG, false, false, true, true, null, Map.of(), null, false, null))
);
private final IndexFieldDataCache fieldDataCache = new IndexFieldDataCache.None();
private final Map<String, Set<String>> sourcePaths = Map.of("n", Set.of("n"));
private final CircuitBreakerService breakerService = new NoneCircuitBreakerService();
private final SearchLookup lookup = new SearchLookup(
fieldTypes::get,
(mft, lookup) -> mft.fielddataBuilder(FieldDataContext.noRuntimeFields("benchmark")).build(fieldDataCache, breakerService)
(mft, lookup, fdo) -> mft.fielddataBuilder(FieldDataContext.noRuntimeFields("benchmark")).build(fieldDataCache, breakerService)
);

@Param({ "expression", "metal", "painless_cast", "painless_def" })
Expand Down Expand Up @@ -152,7 +154,7 @@ private Query scriptScoreQuery(ScoreScript.Factory factory) {
private ScoreScript.Factory bareMetalScript() {
return (params, lookup) -> {
MappedFieldType type = fieldTypes.get("n");
IndexNumericFieldData ifd = (IndexNumericFieldData) lookup.getForField(type);
IndexNumericFieldData ifd = (IndexNumericFieldData) lookup.getForField(type, MappedFieldType.FielddataOperation.SEARCH);
return new ScoreScript.LeafFactory() {
@Override
public ScoreScript newInstance(DocReader docReader) throws IOException {
Expand Down
5 changes: 5 additions & 0 deletions docs/changelog/88735.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pr: 88735
summary: Add source fallback for keyword fields using operation
area: Mapping
type: enhancement
issues: []
Original file line number Diff line number Diff line change
Expand Up @@ -460,7 +460,7 @@ private static DoubleValuesSource getDocValueSource(String variable, SearchLooku
throw new ParseException("Field [" + fieldname + "] does not exist in mappings", 5);
}

IndexFieldData<?> fieldData = lookup.getForField(fieldType);
IndexFieldData<?> fieldData = lookup.getForField(fieldType, MappedFieldType.FielddataOperation.SEARCH);
final DoubleValuesSource valueSource;
if (fieldType instanceof GeoPointFieldType) {
// geo
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public void setUp() throws Exception {
when(fieldData.load(any())).thenReturn(atomicFieldData);

service = new ExpressionScriptEngine();
lookup = new SearchLookup(field -> field.equals("field") ? fieldType : null, (ignored, _lookup) -> fieldData);
lookup = new SearchLookup(field -> field.equals("field") ? fieldType : null, (ignored, _lookup, fdt) -> fieldData);
}

private FieldScript.LeafFactory compile(String expression) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ public void setUp() throws Exception {
when(fieldData.load(any())).thenReturn(atomicFieldData);

service = new ExpressionScriptEngine();
lookup = new SearchLookup(field -> field.equals("field") ? fieldType : null, (ignored, _lookup) -> fieldData);
lookup = new SearchLookup(field -> field.equals("field") ? fieldType : null, (ignored, _lookup, fdt) -> fieldData);
}

private NumberSortScript.LeafFactory compile(String expression) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ public void setUp() throws Exception {
when(fieldData.load(any())).thenReturn(atomicFieldData);

service = new ExpressionScriptEngine();
lookup = new SearchLookup(field -> field.equals("field") ? fieldType : null, (ignored, _lookup) -> fieldData);
lookup = new SearchLookup(field -> field.equals("field") ? fieldType : null, (ignored, _lookup, fdt) -> fieldData);
}

private TermsSetQueryScript.LeafFactory compile(String expression) {
Expand Down
Loading