Class DocumentParserContext

java.lang.Object
org.elasticsearch.index.mapper.DocumentParserContext

public abstract class DocumentParserContext extends Object
Context used when parsing incoming documents. Holds everything that is needed to parse a document as well as the lucene data structures and mappings to be dynamically created as the outcome of parsing a document.
  • Constructor Details

  • Method Details

    • indexSettings

      public final IndexSettings indexSettings()
    • indexAnalyzers

      public final IndexAnalyzers indexAnalyzers()
    • root

      public final RootObjectMapper root()
    • parent

      public final ObjectMapper parent()
    • mappingLookup

      public final MappingLookup mappingLookup()
    • getMetadataMapper

      public final MetadataFieldMapper getMetadataMapper(String mapperName)
    • dynamicTemplateParserContext

      public final MappingParserContext dynamicTemplateParserContext(DateFormatter dateFormatter)
    • sourceToParse

      public final SourceToParse sourceToParse()
    • addIgnoredField

      public final void addIgnoredField(String field)
      Add the given field to the set of ignored fields.
    • getIgnoredFields

      public final Collection<String> getIgnoredFields()
      Return the collection of fields that have been ignored so far.
    • addToFieldNames

      public final void addToFieldNames(String field)
      Add the given field to the _field_names field Use this if an exists query run against the field cannot use docvalues or norms.
    • version

      public final org.apache.lucene.document.Field version()
    • version

      public final void version(org.apache.lucene.document.Field version)
    • id

      public final String id()
    • id

      public final void id(String id)
    • seqID

      public final SeqNoFieldMapper.SequenceIDFields seqID()
    • seqID

      public final void seqID(SeqNoFieldMapper.SequenceIDFields seqID)
    • documentDescription

      public final String documentDescription()
      Description on the document being parsed used in error messages. Not called unless there is an error.
    • getMapper

      public Mapper getMapper(String name)
    • dynamic

      public ObjectMapper.Dynamic dynamic()
    • markFieldAsAppliedFromTemplate

      public void markFieldAsAppliedFromTemplate(String fieldName)
    • isFieldAppliedFromTemplate

      public boolean isFieldAppliedFromTemplate(String name)
    • markFieldAsCopyTo

      public void markFieldAsCopyTo(String fieldName)
    • isCopyToField

      public boolean isCopyToField(String name)
    • addDynamicMapper

      public final void addDynamicMapper(String fullName, Mapper.Builder builder)
      Add a new mapper dynamically created while parsing.
    • getDynamicMappers

      public final Map<String,List<Mapper.Builder>> getDynamicMappers()
      Get dynamic mappers created as a result of parsing an incoming document. Responsible for exposing all the newly created fields that need to be merged into the existing mappings. Used to create the required mapping update at the end of document parsing. Consists of a all Mappers that will need to be added to their respective parent ObjectMappers in order to become part of the resulting dynamic mapping update.
    • getDynamicMappers

      public final List<Mapper.Builder> getDynamicMappers(String fieldName)
      Returns the dynamic Consists of a flat set of Mappers associated with a field name that will need to be added to their respective parent ObjectMappers in order to become part of the resulting dynamic mapping update.
      Parameters:
      fieldName - Full field name with dot-notation.
      Returns:
      List of Mappers or null
    • updateDynamicMappers

      public void updateDynamicMappers(String name, Mapper.Builder mapper)
    • getDynamicRuntimeFields

      public final List<RuntimeField> getDynamicRuntimeFields()
      Get dynamic runtime fields created while parsing. Holds a flat set of RuntimeFields. Runtime fields get dynamically mapped when ObjectMapper.Dynamic.RUNTIME is used, or when dynamic templates specify a runtime section.
    • nonRootDocuments

      public abstract Iterable<LuceneDocument> nonRootDocuments()
      Returns an Iterable over all non-root documents. If there are no non-root documents the iterable will return an empty iterator.
    • updateRoot

      public final RootObjectMapper.Builder updateRoot()
      Returns:
      a RootObjectMapper.Builder to be used to construct a dynamic mapping update
    • isWithinCopyTo

      public boolean isWithinCopyTo()
    • createChildContext

      public final DocumentParserContext createChildContext(ObjectMapper parent)
    • createNestedContext

      public final DocumentParserContext createNestedContext(NestedObjectMapper nestedMapper)
      Return a new context that will be used within a nested document.
    • switchDoc

      public final DocumentParserContext switchDoc(LuceneDocument document)
      Return a new context that has the provided document as the current document.
    • createCopyToContext

      public final DocumentParserContext createCopyToContext(String copyToField, LuceneDocument doc) throws IOException
      Return a context for copy_to directives
      Parameters:
      copyToField - the name of the field to copy to
      doc - the document to target
      Throws:
      IOException
    • createFlattenContext

      public final DocumentParserContext createFlattenContext(String fieldName)
      Return a context for flattening subobjects
      Parameters:
      fieldName - the name of the field to be flattened
    • switchParser

      @Deprecated public final DocumentParserContext switchParser(XContentParser parser)
      Deprecated.
      we are actively deprecating and removing the ability to pass complex objects to multifields, so try and avoid using this method Replace the XContentParser used by this context
      Parameters:
      parser - the replacement parser
      Returns:
      a new context with a replaced parser
    • getDimensions

      public DocumentDimensions getDimensions()
      The collection of dimensions for this document.
    • path

      public abstract ContentPath path()
    • createDynamicMapperBuilderContext

      public final MapperBuilderContext createDynamicMapperBuilderContext()
      Creates a context to build dynamic mappers
    • parser

      public abstract XContentParser parser()
    • rootDoc

      public abstract LuceneDocument rootDoc()
    • doc

      public abstract LuceneDocument doc()
    • addDoc

      protected abstract void addDoc(LuceneDocument doc)
    • findDynamicTemplate

      public final DynamicTemplate findDynamicTemplate(String fieldName, DynamicTemplate.XContentFieldType matchType)
      Find a dynamic mapping template for the given field and its matching type
      Parameters:
      fieldName - the name of the field
      matchType - the expecting matchType of the field
      Returns:
      the matching template; otherwise returns null
      Throws:
      DocumentParsingException - if the given field has a dynamic template name specified, but no template matches that name.