Class FieldMapper

java.lang.Object
org.elasticsearch.index.mapper.Mapper
org.elasticsearch.index.mapper.FieldMapper
All Implemented Interfaces:
java.lang.Cloneable, java.lang.Iterable<Mapper>, org.elasticsearch.common.xcontent.ToXContent, org.elasticsearch.common.xcontent.ToXContentFragment
Direct Known Subclasses:
AbstractGeometryFieldMapper, BinaryFieldMapper, BooleanFieldMapper, CompletionFieldMapper, DateFieldMapper, DynamicKeyFieldMapper, IpFieldMapper, KeywordFieldMapper, MetadataFieldMapper, NumberFieldMapper, RangeFieldMapper, TextFieldMapper

public abstract class FieldMapper
extends Mapper
implements java.lang.Cloneable
  • Field Details

    • IGNORE_MALFORMED_SETTING

      public static final Setting<java.lang.Boolean> IGNORE_MALFORMED_SETTING
    • COERCE_SETTING

      public static final Setting<java.lang.Boolean> COERCE_SETTING
    • mappedFieldType

      protected final MappedFieldType mappedFieldType
    • indexAnalyzers

      protected final java.util.Map<java.lang.String,​NamedAnalyzer> indexAnalyzers
    • multiFields

      protected final FieldMapper.MultiFields multiFields
    • copyTo

      protected final FieldMapper.CopyTo copyTo
  • Constructor Details

    • FieldMapper

      protected FieldMapper​(java.lang.String simpleName, MappedFieldType mappedFieldType, FieldMapper.MultiFields multiFields, FieldMapper.CopyTo copyTo)
      Create a FieldMapper with no index analyzers
      Parameters:
      simpleName - the leaf name of the mapper
      mappedFieldType - the MappedFieldType associated with this mapper
      multiFields - sub fields of this mapper
      copyTo - copyTo fields of this mapper
    • FieldMapper

      protected FieldMapper​(java.lang.String simpleName, MappedFieldType mappedFieldType, NamedAnalyzer indexAnalyzer, FieldMapper.MultiFields multiFields, FieldMapper.CopyTo copyTo)
      Create a FieldMapper with a single associated index analyzer
      Parameters:
      simpleName - the leaf name of the mapper
      mappedFieldType - the MappedFieldType associated with this mapper
      indexAnalyzer - the index-time analyzer to use for this field
      multiFields - sub fields of this mapper
      copyTo - copyTo fields of this mapper
    • FieldMapper

      protected FieldMapper​(java.lang.String simpleName, MappedFieldType mappedFieldType, java.util.Map<java.lang.String,​NamedAnalyzer> indexAnalyzers, FieldMapper.MultiFields multiFields, FieldMapper.CopyTo copyTo)
      Create a FieldMapper that indexes into multiple analyzed fields
      Parameters:
      simpleName - the leaf name of the mapper
      mappedFieldType - the MappedFieldType associated with this mapper
      indexAnalyzers - a map of field names to analyzers, one for each analyzed field the mapper will add
      multiFields - sub fields of this mapper
      copyTo - copyTo fields of this mapper
  • Method Details

    • name

      public java.lang.String name()
      Description copied from class: Mapper
      Returns the canonical name which uniquely identifies the mapper against other mappers in a type.
      Specified by:
      name in class Mapper
    • typeName

      public java.lang.String typeName()
      Description copied from class: Mapper
      Returns a name representing the type of this mapper.
      Specified by:
      typeName in class Mapper
    • fieldType

      public MappedFieldType fieldType()
    • copyTo

      public FieldMapper.CopyTo copyTo()
      List of fields where this field should be copied to
    • multiFields

      public FieldMapper.MultiFields multiFields()
    • parsesArrayValue

      public boolean parsesArrayValue()
      Whether this mapper can handle an array value during document parsing. If true, when an array is encountered during parsing, the document parser will pass the whole array to the mapper. If false, the array is split into individual values and each value is passed to the mapper for parsing.
    • parse

      public void parse​(ParseContext context) throws java.io.IOException
      Parse the field value using the provided ParseContext.
      Throws:
      java.io.IOException
    • parseCreateField

      protected abstract void parseCreateField​(ParseContext context) throws java.io.IOException
      Parse the field value and populate the fields on ParseContext.doc(). Implementations of this method should ensure that on failing to parse parser.currentToken() must be the current failing token
      Throws:
      java.io.IOException
    • createFieldNamesField

      protected final void createFieldNamesField​(ParseContext context)
    • iterator

      public java.util.Iterator<Mapper> iterator()
      Specified by:
      iterator in interface java.lang.Iterable<Mapper>
    • validate

      public final void validate​(MappingLookup mappers)
      Description copied from class: Mapper
      Validate any cross-field references made by this mapper
      Specified by:
      validate in class Mapper
      Parameters:
      mappers - a MappingLookup that can produce references to other mappers
    • doValidate

      protected void doValidate​(MappingLookup mappers)
    • getMergeBuilder

      public abstract FieldMapper.Builder getMergeBuilder()
      Returns a FieldMapper.Builder to be used for merging and serialization Implement as follows: return new MyBuilder(simpleName()).init(this);
    • merge

      public final FieldMapper merge​(Mapper mergeWith)
      Description copied from class: Mapper
      Return the merge of mergeWith into this. Both this and mergeWith will be left unmodified.
      Specified by:
      merge in class Mapper
    • checkIncomingMergeType

      protected void checkIncomingMergeType​(FieldMapper mergeWith)
    • toXContent

      public org.elasticsearch.common.xcontent.XContentBuilder toXContent​(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.xcontent.ToXContent.Params params) throws java.io.IOException
      Specified by:
      toXContent in interface org.elasticsearch.common.xcontent.ToXContent
      Throws:
      java.io.IOException
    • doXContentBody

      protected void doXContentBody​(org.elasticsearch.common.xcontent.XContentBuilder builder, boolean includeDefaults, org.elasticsearch.common.xcontent.ToXContent.Params params) throws java.io.IOException
      Throws:
      java.io.IOException
    • contentType

      protected abstract java.lang.String contentType()
    • indexAnalyzers

      public final java.util.Map<java.lang.String,​NamedAnalyzer> indexAnalyzers()