- All Known Implementing Classes:
ArraySourceValueFetcher
,DocValueFetcher
,NestedValueFetcher
,SourceValueFetcher
,StoredValueFetcher
public interface ValueFetcher
A helper class for fetching field values during the
FetchFieldsPhase
. Each MappedFieldType
is in charge of defining a value fetcher through MappedFieldType.valueFetcher(org.elasticsearch.index.query.SearchExecutionContext, java.lang.String)
.-
Field Summary
Fields -
Method Summary
Modifier and TypeMethodDescriptiondefault DocumentField
fetchDocumentField
(String docName, Source lookup, int doc) Prefer implementingfetchValues(Source, int, List)
, which is simpler, when possible instead of this method.fetchValues
(Source source, int doc, List<Object> ignoredValues) This method is consumed byfetchDocumentField(String, Source, int)
.default void
setNextReader
(org.apache.lucene.index.LeafReaderContext context) Update the leaf reader used to fetch values.static ValueFetcher
The stored field or source requirements of this value fetcher
-
Field Details
-
EMPTY
-
-
Method Details
-
fetchValues
This method is consumed byfetchDocumentField(String, Source, int)
. Given access to a document's _source, return this field's values.In addition to pulling out the values, they will be parsed into a standard form. For example numeric field mappers make sure to parse the source value into a number of the right type.
Note that for array values, the order in which values are returned is undefined and should not be relied on.
- Parameters:
source
- the document's source.doc
- the document idignoredValues
- a mutable list to collect any ignored values as they were originally presented in source- Returns:
- a list a standardized field values.
- Throws:
IOException
-
fetchDocumentField
@Nullable default DocumentField fetchDocumentField(String docName, Source lookup, int doc) throws IOException Prefer implementingfetchValues(Source, int, List)
, which is simpler, when possible instead of this method. The default implementation creates aDocumentField
using the values fromfetchValues(Source, int, List)
- Parameters:
docName
- the name of the document fieldlookup
- a lookup structure over the document's source.doc
- the document id- Returns:
- a document field if this fetcher has values; otherwise returns null
- Throws:
IOException
-
setNextReader
default void setNextReader(org.apache.lucene.index.LeafReaderContext context) Update the leaf reader used to fetch values. -
storedFieldsSpec
StoredFieldsSpec storedFieldsSpec()The stored field or source requirements of this value fetcher -
singleton
-