Class ArraySourceValueFetcher

java.lang.Object
org.elasticsearch.index.mapper.ArraySourceValueFetcher
All Implemented Interfaces:
ValueFetcher

public abstract class ArraySourceValueFetcher
extends java.lang.Object
implements ValueFetcher
An implementation of ValueFetcher that knows how to extract values from the document source.

This class differs from SourceValueFetcher in that it directly handles array values in parsing. Field types should use this class if their corresponding mapper returns true for FieldMapper.parsesArrayValue().

  • Constructor Summary

    Constructors
    Constructor Description
    ArraySourceValueFetcher​(java.lang.String fieldName, SearchExecutionContext context)  
    ArraySourceValueFetcher​(java.lang.String fieldName, SearchExecutionContext context, java.lang.Object nullValue)  
  • Method Summary

    Modifier and Type Method Description
    java.util.List<java.lang.Object> fetchValues​(SourceLookup lookup)
    Given access to a document's _source, return this field's values.
    protected abstract java.lang.Object parseSourceValue​(java.lang.Object value)
    Given a value that has been extracted from a document's source, parse it into a standard format.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.elasticsearch.index.mapper.ValueFetcher

    setNextReader
  • Constructor Details

    • ArraySourceValueFetcher

      public ArraySourceValueFetcher​(java.lang.String fieldName, SearchExecutionContext context)
    • ArraySourceValueFetcher

      public ArraySourceValueFetcher​(java.lang.String fieldName, SearchExecutionContext context, java.lang.Object nullValue)
      Parameters:
      fieldName - The name of the field.
      context - The query shard context
      nullValue - A optional substitute value if the _source value is 'null'.
  • Method Details

    • fetchValues

      public java.util.List<java.lang.Object> 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 java.lang.Object parseSourceValue​(java.lang.Object 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).