Skip to content

Commit 4e5bd65

Browse files
committed
Close over lookup
1 parent 6a6584b commit 4e5bd65

File tree

36 files changed

+74
-77
lines changed

36 files changed

+74
-77
lines changed

modules/mapper-extras/src/main/java/org/elasticsearch/index/mapper/RankFeatureFieldMapper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ public ValueFetcher valueFetcher(MapperService mapperService, SearchLookup searc
187187
if (format != null) {
188188
throw new IllegalArgumentException("Field [" + name() + "] of type [" + typeName() + "] doesn't support formats.");
189189
}
190-
return new SourceValueFetcher(name(), mapperService, parsesArrayValue()) {
190+
return new SourceValueFetcher(name(), mapperService, searchLookup.source(), parsesArrayValue()) {
191191
@Override
192192
protected Float parseSourceValue(Object value) {
193193
return objectToFloat(value);

modules/mapper-extras/src/main/java/org/elasticsearch/index/mapper/RankFeaturesFieldMapper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ public ValueFetcher valueFetcher(MapperService mapperService, SearchLookup searc
166166
if (format != null) {
167167
throw new IllegalArgumentException("Field [" + name() + "] of type [" + typeName() + "] doesn't support formats.");
168168
}
169-
return new SourceValueFetcher(name(), mapperService, parsesArrayValue()) {
169+
return new SourceValueFetcher(name(), mapperService, searchLookup.source(), parsesArrayValue()) {
170170
@Override
171171
protected Object parseSourceValue(Object value) {
172172
return value;

modules/mapper-extras/src/main/java/org/elasticsearch/index/mapper/ScaledFloatFieldMapper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -401,7 +401,7 @@ public ValueFetcher valueFetcher(MapperService mapperService, SearchLookup searc
401401
if (format != null) {
402402
throw new IllegalArgumentException("Field [" + name() + "] of type [" + typeName() + "] doesn't support formats.");
403403
}
404-
return new SourceValueFetcher(name(), mapperService, parsesArrayValue()) {
404+
return new SourceValueFetcher(name(), mapperService, searchLookup.source(), parsesArrayValue()) {
405405
@Override
406406
protected Double parseSourceValue(Object value) {
407407
double doubleValue;

modules/mapper-extras/src/main/java/org/elasticsearch/index/mapper/TokenCountFieldMapper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -165,7 +165,7 @@ public ValueFetcher valueFetcher(MapperService mapperService, SearchLookup searc
165165
throw new IllegalArgumentException("Field [" + name() + "] of type [" + typeName() + "] doesn't support formats.");
166166
}
167167

168-
return new SourceValueFetcher(name(), mapperService, parsesArrayValue(), nullValue) {
168+
return new SourceValueFetcher(name(), mapperService, searchLookup.source(), parsesArrayValue(), nullValue) {
169169
@Override
170170
protected String parseSourceValue(Object value) {
171171
return value.toString();

modules/parent-join/src/main/java/org/elasticsearch/join/mapper/ParentJoinFieldMapper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ public ValueFetcher valueFetcher(MapperService mapperService, SearchLookup searc
356356
if (format != null) {
357357
throw new IllegalArgumentException("Field [" + name() + "] of type [" + typeName() + "] doesn't support formats.");
358358
}
359-
return new SourceValueFetcher(name(), mapperService, parsesArrayValue()) {
359+
return new SourceValueFetcher(name(), mapperService, searchLookup.source(), parsesArrayValue()) {
360360
@Override
361361
protected Object parseSourceValue(Object value) {
362362
return value;

modules/percolator/src/main/java/org/elasticsearch/percolator/PercolatorFieldMapper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -371,7 +371,7 @@ public ValueFetcher valueFetcher(MapperService mapperService, SearchLookup searc
371371
if (format != null) {
372372
throw new IllegalArgumentException("Field [" + name() + "] of type [" + typeName() + "] doesn't support formats.");
373373
}
374-
return new SourceValueFetcher(name(), mapperService, parsesArrayValue()) {
374+
return new SourceValueFetcher(name(), mapperService, searchLookup.source(), parsesArrayValue()) {
375375
@Override
376376
protected Object parseSourceValue(Object value) {
377377
return value;

plugins/analysis-icu/src/main/java/org/elasticsearch/index/mapper/ICUCollationKeywordFieldMapper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -740,7 +740,7 @@ public ValueFetcher valueFetcher(MapperService mapperService, SearchLookup searc
740740
throw new IllegalArgumentException("Field [" + name() + "] of type [" + typeName() + "] doesn't support formats.");
741741
}
742742

743-
return new SourceValueFetcher(name(), mapperService, parsesArrayValue(), nullValue) {
743+
return new SourceValueFetcher(name(), mapperService, searchLookup.source(), parsesArrayValue(), nullValue) {
744744
@Override
745745
protected String parseSourceValue(Object value) {
746746
String keywordValue = value.toString();

plugins/mapper-annotated-text/src/main/java/org/elasticsearch/index/mapper/annotatedtext/AnnotatedTextFieldMapper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -594,7 +594,7 @@ public ValueFetcher valueFetcher(MapperService mapperService, SearchLookup searc
594594
if (format != null) {
595595
throw new IllegalArgumentException("Field [" + name() + "] of type [" + typeName() + "] doesn't support formats.");
596596
}
597-
return new SourceValueFetcher(name(), mapperService, parsesArrayValue()) {
597+
return new SourceValueFetcher(name(), mapperService, searchLookup.source(), parsesArrayValue()) {
598598
@Override
599599
protected Object parseSourceValue(Object value) {
600600
return value.toString();

plugins/mapper-murmur3/src/main/java/org/elasticsearch/index/mapper/murmur3/Murmur3FieldMapper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -157,7 +157,7 @@ public ValueFetcher valueFetcher(MapperService mapperService, SearchLookup searc
157157
if (format != null) {
158158
throw new IllegalArgumentException("Field [" + name() + "] of type [" + typeName() + "] doesn't support formats.");
159159
}
160-
return new SourceValueFetcher(name(), mapperService, parsesArrayValue()) {
160+
return new SourceValueFetcher(name(), mapperService, searchLookup.source(), parsesArrayValue()) {
161161
@Override
162162
protected String parseSourceValue(Object value) {
163163
return value.toString();

server/src/main/java/org/elasticsearch/index/mapper/AbstractGeometryFieldMapper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -192,7 +192,7 @@ public ValueFetcher valueFetcher(MapperService mapperService, SearchLookup searc
192192
Parser<Parsed> geometryParser = mappedFieldType.geometryParser();
193193
Function<Object, Object> valueParser = value -> geometryParser.parseAndFormatObject(value, this, geoFormat);
194194

195-
return new SourceValueFetcher(name(), mapperService, parsesArrayValue()) {
195+
return new SourceValueFetcher(name(), mapperService, searchLookup.source(), parsesArrayValue()) {
196196
@Override
197197
protected Object parseSourceValue(Object value) {
198198
return valueParser.apply(value);

server/src/main/java/org/elasticsearch/index/mapper/BinaryFieldMapper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ public ValueFetcher valueFetcher(MapperService mapperService, SearchLookup searc
196196
if (format != null) {
197197
throw new IllegalArgumentException("Field [" + name() + "] of type [" + typeName() + "] doesn't support formats.");
198198
}
199-
return new SourceValueFetcher(name(), mapperService, parsesArrayValue()) {
199+
return new SourceValueFetcher(name(), mapperService, searchLookup.source(), parsesArrayValue()) {
200200
@Override
201201
protected Object parseSourceValue(Object value) {
202202
return value;

server/src/main/java/org/elasticsearch/index/mapper/BooleanFieldMapper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -258,7 +258,7 @@ public ValueFetcher valueFetcher(MapperService mapperService, SearchLookup searc
258258
throw new IllegalArgumentException("Field [" + name() + "] of type [" + typeName() + "] doesn't support formats.");
259259
}
260260

261-
return new SourceValueFetcher(name(), mapperService, parsesArrayValue(), nullValue) {
261+
return new SourceValueFetcher(name(), mapperService, searchLookup.source(), parsesArrayValue(), nullValue) {
262262
@Override
263263
protected Boolean parseSourceValue(Object value) {
264264
if (value instanceof Boolean) {

server/src/main/java/org/elasticsearch/index/mapper/CompletionFieldMapper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -546,7 +546,7 @@ public ValueFetcher valueFetcher(MapperService mapperService, SearchLookup searc
546546
throw new IllegalArgumentException("Field [" + name() + "] of type [" + typeName() + "] doesn't support formats.");
547547
}
548548

549-
return new SourceValueFetcher(name(), mapperService, parsesArrayValue()) {
549+
return new SourceValueFetcher(name(), mapperService, searchLookup.source(), parsesArrayValue()) {
550550
@Override
551551
protected List<?> parseSourceValue(Object value) {
552552
if (value instanceof List) {

server/src/main/java/org/elasticsearch/index/mapper/DateFieldMapper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -612,7 +612,7 @@ public ValueFetcher valueFetcher(MapperService mapperService, SearchLookup searc
612612
? DateFormatter.forPattern(format).withLocale(defaultFormatter.locale())
613613
: defaultFormatter;
614614

615-
return new SourceValueFetcher(name(), mapperService, parsesArrayValue(), nullValueAsString) {
615+
return new SourceValueFetcher(name(), mapperService, searchLookup.source(), parsesArrayValue(), nullValueAsString) {
616616
@Override
617617
public String parseSourceValue(Object value) {
618618
String date = value.toString();

server/src/main/java/org/elasticsearch/index/mapper/DocValueFetcher.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import org.apache.lucene.index.LeafReaderContext;
2323
import org.elasticsearch.index.fielddata.IndexFieldData;
2424
import org.elasticsearch.search.DocValueFormat;
25-
import org.elasticsearch.search.lookup.SourceLookup;
2625

2726
import java.io.IOException;
2827
import java.util.ArrayList;
@@ -46,8 +45,8 @@ public void setNextReader(LeafReaderContext context) {
4645
}
4746

4847
@Override
49-
public List<Object> fetchValues(SourceLookup lookup) throws IOException {
50-
if (false == leaf.advanceExact(lookup.docId())) {
48+
public List<Object> fetchValues(int docId) throws IOException {
49+
if (false == leaf.advanceExact(docId)) {
5150
return List.of();
5251
}
5352
List<Object> result = new ArrayList<Object>(leaf.docValueCount());

server/src/main/java/org/elasticsearch/index/mapper/IpFieldMapper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -408,7 +408,7 @@ public ValueFetcher valueFetcher(MapperService mapperService, SearchLookup searc
408408
if (format != null) {
409409
throw new IllegalArgumentException("Field [" + name() + "] of type [" + typeName() + "] doesn't support formats.");
410410
}
411-
return new SourceValueFetcher(name(), mapperService, parsesArrayValue(), nullValue) {
411+
return new SourceValueFetcher(name(), mapperService, searchLookup.source(), parsesArrayValue(), nullValue) {
412412
@Override
413413
protected Object parseSourceValue(Object value) {
414414
InetAddress address;

server/src/main/java/org/elasticsearch/index/mapper/KeywordFieldMapper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -398,7 +398,7 @@ public ValueFetcher valueFetcher(MapperService mapperService, SearchLookup searc
398398
throw new IllegalArgumentException("Field [" + name() + "] of type [" + typeName() + "] doesn't support formats.");
399399
}
400400

401-
return new SourceValueFetcher(name(), mapperService, parsesArrayValue(), nullValue) {
401+
return new SourceValueFetcher(name(), mapperService, searchLookup.source(), parsesArrayValue(), nullValue) {
402402
@Override
403403
protected String parseSourceValue(Object value) {
404404
String keywordValue = value.toString();

server/src/main/java/org/elasticsearch/index/mapper/NumberFieldMapper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1094,7 +1094,7 @@ public ValueFetcher valueFetcher(MapperService mapperService, SearchLookup searc
10941094
throw new IllegalArgumentException("Field [" + name() + "] of type [" + typeName() + "] doesn't support formats.");
10951095
}
10961096

1097-
return new SourceValueFetcher(name(), mapperService, parsesArrayValue(), nullValue) {
1097+
return new SourceValueFetcher(name(), mapperService, searchLookup.source(), parsesArrayValue(), nullValue) {
10981098
@Override
10991099
protected Object parseSourceValue(Object value) {
11001100
if (value.equals("")) {

server/src/main/java/org/elasticsearch/index/mapper/RangeFieldMapper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -366,7 +366,7 @@ public ValueFetcher valueFetcher(MapperService mapperService, SearchLookup searc
366366
? DateFormatter.forPattern(format).withLocale(defaultFormatter.locale())
367367
: defaultFormatter;
368368

369-
return new SourceValueFetcher(name(), mapperService, parsesArrayValue()) {
369+
return new SourceValueFetcher(name(), mapperService, searchLookup.source(), parsesArrayValue()) {
370370

371371
@Override
372372
@SuppressWarnings("unchecked")

server/src/main/java/org/elasticsearch/index/mapper/SourceValueFetcher.java

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -35,26 +35,38 @@
3535
*/
3636
public abstract class SourceValueFetcher implements ValueFetcher {
3737
private final Set<String> sourcePaths;
38+
private final SourceLookup lookup;
3839
private final @Nullable Object nullValue;
3940
private final boolean parsesArrayValue;
4041

41-
public SourceValueFetcher(String fieldName, MapperService mapperService, boolean parsesArrayValue) {
42-
this(fieldName, mapperService, parsesArrayValue, null);
42+
public SourceValueFetcher(String fieldName, MapperService mapperService, SourceLookup lookup, boolean parsesArrayValue) {
43+
this(fieldName, mapperService, lookup, parsesArrayValue, null);
4344
}
4445

4546
/**
4647
* @param fieldName The name of the field.
4748
* @param parsesArrayValue Whether the fetcher handles array values during document parsing.
4849
* @param nullValue A optional substitute value if the _source value is 'null'.
4950
*/
50-
public SourceValueFetcher(String fieldName, MapperService mapperService, boolean parsesArrayValue, Object nullValue) {
51+
public SourceValueFetcher(
52+
String fieldName,
53+
MapperService mapperService,
54+
SourceLookup lookup,
55+
boolean parsesArrayValue,
56+
Object nullValue
57+
) {
5158
this.sourcePaths = mapperService.sourcePath(fieldName);
59+
this.lookup = lookup;
5260
this.nullValue = nullValue;
5361
this.parsesArrayValue = parsesArrayValue;
5462
}
5563

5664
@Override
57-
public List<Object> fetchValues(SourceLookup lookup) {
65+
public List<Object> fetchValues(int docId) {
66+
/*
67+
* Pulls the values from the source, parses them and then them
68+
* using parseSourceValue.
69+
*/
5870
List<Object> values = new ArrayList<>();
5971
for (String path : sourcePaths) {
6072
Object sourceValue = lookup.extractValue(path, nullValue);

server/src/main/java/org/elasticsearch/index/mapper/TextFieldMapper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -841,7 +841,7 @@ public ValueFetcher valueFetcher(MapperService mapperService, SearchLookup searc
841841
if (format != null) {
842842
throw new IllegalArgumentException("Field [" + name() + "] of type [" + typeName() + "] doesn't support formats.");
843843
}
844-
return new SourceValueFetcher(name(), mapperService, parsesArrayValue()) {
844+
return new SourceValueFetcher(name(), mapperService, searchLookup.source(), parsesArrayValue()) {
845845
@Override
846846
protected Object parseSourceValue(Object value) {
847847
return value.toString();

server/src/main/java/org/elasticsearch/index/mapper/ValueFetcher.java

Lines changed: 5 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121

2222
import org.apache.lucene.index.LeafReaderContext;
2323
import org.elasticsearch.search.fetch.subphase.FetchFieldsPhase;
24-
import org.elasticsearch.search.lookup.SourceLookup;
2524

2625
import java.io.IOException;
2726
import java.util.List;
@@ -32,19 +31,16 @@
3231
*/
3332
public interface ValueFetcher {
3433
/**
35-
* Given access to a document's _source, return this field's values.
36-
*
37-
* In addition to pulling out the values, they will be parsed into a standard form.
38-
* For example numeric field mappers make sure to parse the source value into a number
39-
* of the right type.
40-
*
34+
* Fetch this field's values, converting them into a "standard form" and applying
35+
* any formats configured when the {@linkplain ValueFetcher} was built.
36+
* <p>
4137
* Note that for array values, the order in which values are returned is undefined and
4238
* should not be relied on.
4339
*
44-
* @param lookup a lookup structure over the document's source.
40+
* @param docId the document's id.
4541
* @return a list a standardized field values.
4642
*/
47-
List<Object> fetchValues(SourceLookup lookup) throws IOException;
43+
List<Object> fetchValues(int docId) throws IOException;
4844

4945
/**
5046
* Update the leaf reader used to fetch values.

server/src/main/java/org/elasticsearch/search/fetch/subphase/FetchDocValuesPhase.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ public void process(HitContext hit) throws IOException {
8686
// docValues fields will still be document fields, and put under "fields" section of a hit.
8787
hit.hit().setDocumentField(f.getKey(), hitField);
8888
}
89-
hitField.getValues().addAll(f.getValue().fetchValues(hit.sourceLookup()));
89+
hitField.getValues().addAll(f.getValue().fetchValues(hit.docId()));
9090
}
9191
}
9292
};

server/src/main/java/org/elasticsearch/search/fetch/subphase/FetchFieldsPhase.java

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
import org.elasticsearch.search.fetch.FetchSubPhaseProcessor;
2828
import org.elasticsearch.search.internal.SearchContext;
2929
import org.elasticsearch.search.lookup.SearchLookup;
30-
import org.elasticsearch.search.lookup.SourceLookup;
3130

3231
import java.io.IOException;
3332
import java.util.HashSet;
@@ -60,10 +59,8 @@ public void setNextReader(LeafReaderContext readerContext) {
6059
@Override
6160
public void process(HitContext hitContext) throws IOException {
6261
SearchHit hit = hitContext.hit();
63-
SourceLookup sourceLookup = hitContext.sourceLookup();
64-
6562
Set<String> ignoredFields = getIgnoredFields(hit);
66-
Map<String, DocumentField> documentFields = retriever.retrieve(sourceLookup, ignoredFields);
63+
Map<String, DocumentField> documentFields = retriever.retrieve(hit.docId(), ignoredFields);
6764
for (Map.Entry<String, DocumentField> entry : documentFields.entrySet()) {
6865
hit.setDocumentField(entry.getKey(), entry.getValue());
6966
}

server/src/main/java/org/elasticsearch/search/fetch/subphase/FieldValueRetriever.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,6 @@
2828
import org.elasticsearch.index.mapper.MappingLookup;
2929
import org.elasticsearch.index.mapper.ValueFetcher;
3030
import org.elasticsearch.search.lookup.SearchLookup;
31-
import org.elasticsearch.search.lookup.SourceLookup;
3231

3332
import java.io.IOException;
3433
import java.util.ArrayList;
@@ -83,7 +82,7 @@ private FieldValueRetriever(List<FieldContext> fieldContexts) {
8382
this.fieldContexts = fieldContexts;
8483
}
8584

86-
public Map<String, DocumentField> retrieve(SourceLookup sourceLookup, Set<String> ignoredFields) throws IOException {
85+
public Map<String, DocumentField> retrieve(int docId, Set<String> ignoredFields) throws IOException {
8786
Map<String, DocumentField> documentFields = new HashMap<>();
8887
for (FieldContext context : fieldContexts) {
8988
String field = context.fieldName;
@@ -92,7 +91,7 @@ public Map<String, DocumentField> retrieve(SourceLookup sourceLookup, Set<String
9291
}
9392

9493
ValueFetcher valueFetcher = context.valueFetcher;
95-
List<Object> parsedValues = valueFetcher.fetchValues(sourceLookup);
94+
List<Object> parsedValues = valueFetcher.fetchValues(docId);
9695

9796
if (parsedValues.isEmpty() == false) {
9897
documentFields.put(field, new DocumentField(field, parsedValues));

server/src/test/java/org/elasticsearch/index/mapper/ExternalMapper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ protected void parseCreateField(ParseContext context) throws IOException {
203203

204204
@Override
205205
public ValueFetcher valueFetcher(MapperService mapperService, SearchLookup searchLookup, String format) {
206-
return new SourceValueFetcher(name(), mapperService, parsesArrayValue()) {
206+
return new SourceValueFetcher(name(), mapperService, searchLookup.source(), parsesArrayValue()) {
207207
@Override
208208
protected Object parseSourceValue(Object value) {
209209
return value;

server/src/test/java/org/elasticsearch/index/mapper/FakeStringFieldMapper.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -136,7 +136,7 @@ protected void parseCreateField(ParseContext context) throws IOException {
136136

137137
@Override
138138
public ValueFetcher valueFetcher(MapperService mapperService, SearchLookup searchLookup, String format) {
139-
return new SourceValueFetcher(name(), mapperService, parsesArrayValue()) {
139+
return new SourceValueFetcher(name(), mapperService, searchLookup.source(), parsesArrayValue()) {
140140
@Override
141141
protected String parseSourceValue(Object value) {
142142
return value.toString();

server/src/test/java/org/elasticsearch/search/fetch/subphase/FieldValueRetrieverTests.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@
2626
import org.elasticsearch.common.xcontent.XContentFactory;
2727
import org.elasticsearch.index.IndexService;
2828
import org.elasticsearch.index.mapper.MapperService;
29-
import org.elasticsearch.search.lookup.SourceLookup;
29+
import org.elasticsearch.search.lookup.SearchLookup;
3030
import org.elasticsearch.test.ESSingleNodeTestCase;
3131

3232
import java.io.IOException;
@@ -370,11 +370,11 @@ private Map<String, DocumentField> retrieveFields(MapperService mapperService, X
370370
private Map<String, DocumentField> retrieveFields(MapperService mapperService, XContentBuilder source, List<FieldAndFormat> fields)
371371
throws IOException {
372372

373-
SourceLookup sourceLookup = new SourceLookup();
374-
sourceLookup.setSource(BytesReference.bytes(source));
373+
SearchLookup lookup = new SearchLookup(mapperService, null);
374+
lookup.source().setSource(BytesReference.bytes(source));
375375

376-
FieldValueRetriever fetchFieldsLookup = FieldValueRetriever.create(mapperService, null, fields);
377-
return fetchFieldsLookup.retrieve(sourceLookup, Set.of());
376+
FieldValueRetriever fetchFieldsLookup = FieldValueRetriever.create(mapperService, lookup, fields);
377+
return fetchFieldsLookup.retrieve(0, Set.of());
378378
}
379379

380380
public MapperService createMapperService() throws IOException {

0 commit comments

Comments
 (0)