Class SourceValueFetcher

org.elasticsearch.index.mapper.SourceValueFetcher
All Implemented Interfaces:
ValueFetcher

public abstract class SourceValueFetcher extends implements 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 Details

    • SourceValueFetcher

      public SourceValueFetcher( fieldName, SearchExecutionContext context)
    • SourceValueFetcher

      public SourceValueFetcher( fieldName, SearchExecutionContext context,  nullValue)
      Parameters:
      fieldName - The name of the field.
      context - The query shard context
      nullValue - An optional substitute value if the _source value is 'null'.
    • SourceValueFetcher

      public SourceValueFetcher(<> sourcePaths,  nullValue)
      Parameters:
      sourcePaths - The paths to pull source values from
      nullValue - An optional substitute value if the _source value is `null`
  • Method Details

    • fetchValues

      public <> fetchValues(SourceLookup lookup)
      Description copied from interface: ValueFetcher
      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.
      Specified by:
      fetchValues in interface ValueFetcher
      Parameters:
      lookup - a lookup structure over the document's source.
      Returns:
      a list a standardized field values.
    • parseSourceValue

      protected abstract  parseSourceValue( value)
      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 in FieldMapper.parseCreateField(org.elasticsearch.index.mapper.ParseContext) or FieldMapper.parse(org.elasticsearch.index.mapper.ParseContext).
    • identity

      public static  fieldName, SearchExecutionContext context,  format)
      Creates a SourceValueFetcher that passes through source values unmodified.
    • toString

      public static  fieldName, SearchExecutionContext context,  format)
      Creates a SourceValueFetcher that converts source values to strings.
    • toString

      public static <> sourcePaths)
      Creates a SourceValueFetcher that converts source values to Strings
      Parameters:
      sourcePaths - the paths to fetch values from in the source