mirror of
https://github.com/elastic/elasticsearch.git
synced 2025-04-24 15:17:30 -04:00
Synthetic source error on script loads (#88334)
* Source Lookup refactor with error on script synthetic source load Refactors SourceLookup into a static source lookup used for most cases where we access the source again after the fetch phase, and a re-loading lookup used by scripts. The re-loading lookup now also fails with an error when we are using synthetic source preventing silent failures or non-sensical behavior from scripts.
This commit is contained in:
parent
6f5fa14df0
commit
db5ddb321f
63 changed files with 520 additions and 220 deletions
|
@ -15,6 +15,7 @@ import org.elasticsearch.index.mapper.NumberFieldMapper;
|
|||
import org.elasticsearch.script.FieldScript;
|
||||
import org.elasticsearch.script.ScriptException;
|
||||
import org.elasticsearch.search.lookup.SearchLookup;
|
||||
import org.elasticsearch.search.lookup.SourceLookup;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -49,7 +50,11 @@ public class ExpressionFieldScriptTests extends ESTestCase {
|
|||
when(fieldData.load(any())).thenReturn(atomicFieldData);
|
||||
|
||||
service = new ExpressionScriptEngine();
|
||||
lookup = new SearchLookup(field -> field.equals("field") ? fieldType : null, (ignored, _lookup, fdt) -> fieldData);
|
||||
lookup = new SearchLookup(
|
||||
field -> field.equals("field") ? fieldType : null,
|
||||
(ignored, _lookup, fdt) -> fieldData,
|
||||
new SourceLookup.ReaderSourceProvider()
|
||||
);
|
||||
}
|
||||
|
||||
private FieldScript.LeafFactory compile(String expression) {
|
||||
|
|
|
@ -17,6 +17,7 @@ import org.elasticsearch.script.DocValuesDocReader;
|
|||
import org.elasticsearch.script.NumberSortScript;
|
||||
import org.elasticsearch.script.ScriptException;
|
||||
import org.elasticsearch.search.lookup.SearchLookup;
|
||||
import org.elasticsearch.search.lookup.SourceLookup;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -50,7 +51,11 @@ public class ExpressionNumberSortScriptTests extends ESTestCase {
|
|||
when(fieldData.load(any())).thenReturn(atomicFieldData);
|
||||
|
||||
service = new ExpressionScriptEngine();
|
||||
lookup = new SearchLookup(field -> field.equals("field") ? fieldType : null, (ignored, _lookup, fdt) -> fieldData);
|
||||
lookup = new SearchLookup(
|
||||
field -> field.equals("field") ? fieldType : null,
|
||||
(ignored, _lookup, fdt) -> fieldData,
|
||||
new SourceLookup.ReaderSourceProvider()
|
||||
);
|
||||
}
|
||||
|
||||
private NumberSortScript.LeafFactory compile(String expression) {
|
||||
|
|
|
@ -16,6 +16,7 @@ import org.elasticsearch.index.mapper.NumberFieldMapper.NumberType;
|
|||
import org.elasticsearch.script.ScriptException;
|
||||
import org.elasticsearch.script.TermsSetQueryScript;
|
||||
import org.elasticsearch.search.lookup.SearchLookup;
|
||||
import org.elasticsearch.search.lookup.SourceLookup;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
|
||||
import java.io.IOException;
|
||||
|
@ -49,7 +50,11 @@ public class ExpressionTermsSetQueryTests extends ESTestCase {
|
|||
when(fieldData.load(any())).thenReturn(atomicFieldData);
|
||||
|
||||
service = new ExpressionScriptEngine();
|
||||
lookup = new SearchLookup(field -> field.equals("field") ? fieldType : null, (ignored, _lookup, fdt) -> fieldData);
|
||||
lookup = new SearchLookup(
|
||||
field -> field.equals("field") ? fieldType : null,
|
||||
(ignored, _lookup, fdt) -> fieldData,
|
||||
new SourceLookup.ReaderSourceProvider()
|
||||
);
|
||||
}
|
||||
|
||||
private TermsSetQueryScript.LeafFactory compile(String expression) {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue