mirror of
https://github.com/elastic/elasticsearch.git
synced 2025-04-24 15:17:30 -04:00
Replace SourceLookup with SourceProvider interface (#91540)
SourceLookup mixes up several concerns - lazy loading, map access to scripts, different access providers - and duplicates logic (such as that choosing how to apply filtering) that is better handled directly in the Source interface. This commit removes SourceLookup entirely and replaces it with a new SourceProvider interface, with a simple stored fields reader implementation. SearchLookup implements this interface directly, and the fetch phase uses a custom implementation to provide its separately loaded source to fetch-time scripts.
This commit is contained in:
parent
1bb660c810
commit
c720cdbbbf
89 changed files with 659 additions and 939 deletions
|
@ -15,8 +15,9 @@ 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.search.lookup.Source;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
import org.elasticsearch.xcontent.XContentType;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.text.ParseException;
|
||||
|
@ -53,7 +54,7 @@ public class ExpressionFieldScriptTests extends ESTestCase {
|
|||
lookup = new SearchLookup(
|
||||
field -> field.equals("field") ? fieldType : null,
|
||||
(ignored, _lookup, fdt) -> fieldData,
|
||||
new SourceLookup.ReaderSourceProvider()
|
||||
(ctx, doc) -> Source.empty(XContentType.JSON)
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -17,8 +17,9 @@ 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.search.lookup.Source;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
import org.elasticsearch.xcontent.XContentType;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.text.ParseException;
|
||||
|
@ -54,7 +55,7 @@ public class ExpressionNumberSortScriptTests extends ESTestCase {
|
|||
lookup = new SearchLookup(
|
||||
field -> field.equals("field") ? fieldType : null,
|
||||
(ignored, _lookup, fdt) -> fieldData,
|
||||
new SourceLookup.ReaderSourceProvider()
|
||||
(ctx, doc) -> Source.empty(XContentType.JSON)
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
@ -16,8 +16,9 @@ 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.search.lookup.Source;
|
||||
import org.elasticsearch.test.ESTestCase;
|
||||
import org.elasticsearch.xcontent.XContentType;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.text.ParseException;
|
||||
|
@ -53,7 +54,7 @@ public class ExpressionTermsSetQueryTests extends ESTestCase {
|
|||
lookup = new SearchLookup(
|
||||
field -> field.equals("field") ? fieldType : null,
|
||||
(ignored, _lookup, fdt) -> fieldData,
|
||||
new SourceLookup.ReaderSourceProvider()
|
||||
(ctx, doc) -> Source.empty(XContentType.JSON)
|
||||
);
|
||||
}
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue