Package org.elasticsearch.index.mapper
Class SourceValueFetcher
java.lang.Object
org.elasticsearch.index.mapper.SourceValueFetcher
- All Implemented Interfaces:
ValueFetcher
An implementation of
ValueFetcher that knows how to extract values
from the document source. Most standard field mappers will use this class
to implement value fetching.
Field types that handle arrays directly should instead use ArraySourceValueFetcher.
-
Constructor Summary
ConstructorsConstructorDescriptionSourceValueFetcher(String fieldName, SearchExecutionContext context)SourceValueFetcher(String fieldName, SearchExecutionContext context, Object nullValue)SourceValueFetcher(Set<String> sourcePaths, Object nullValue) -
Method Summary
Modifier and TypeMethodDescriptionfetchValues(SourceLookup lookup)Given access to a document's _source, return this field's values.static SourceValueFetcheridentity(String fieldName, SearchExecutionContext context, String format)Creates aSourceValueFetcherthat passes through source values unmodified.protected abstract ObjectparseSourceValue(Object value)Given a value that has been extracted from a document's source, parse it into a standard format.static SourceValueFetchertoString(String fieldName, SearchExecutionContext context, String format)Creates aSourceValueFetcherthat converts source values to strings.static SourceValueFetcherCreates aSourceValueFetcherthat converts source values to StringsMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.elasticsearch.index.mapper.ValueFetcher
setNextReader
-
Constructor Details
-
SourceValueFetcher
-
SourceValueFetcher
- Parameters:
fieldName- The name of the field.context- The query shard contextnullValue- An optional substitute value if the _source value is 'null'.
-
SourceValueFetcher
- Parameters:
sourcePaths- The paths to pull source values fromnullValue- An optional substitute value if the _source value is `null`
-
-
Method Details
-
fetchValues
Description copied from interface:ValueFetcherGiven 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.- Specified by:
fetchValuesin interfaceValueFetcher- Parameters:
lookup- a lookup structure over the document's source.- Returns:
- a list a standardized field values.
-
parseSourceValue
Given a value that has been extracted from a document's source, parse it into a standard format. This parsing logic should closely mirror the value parsing inFieldMapper.parseCreateField(org.elasticsearch.index.mapper.ParseContext)orFieldMapper.parse(org.elasticsearch.index.mapper.ParseContext). -
identity
public static SourceValueFetcher identity(String fieldName, SearchExecutionContext context, String format)Creates aSourceValueFetcherthat passes through source values unmodified. -
toString
public static SourceValueFetcher toString(String fieldName, SearchExecutionContext context, String format)Creates aSourceValueFetcherthat converts source values to strings. -
toString
Creates aSourceValueFetcherthat converts source values to Strings- Parameters:
sourcePaths- the paths to fetch values from in the source
-