Class MapperService

java.lang.Object
org.elasticsearch.index.AbstractIndexComponent
org.elasticsearch.index.mapper.MapperService
All Implemented Interfaces:
Closeable, AutoCloseable, IndexComponent

public class MapperService extends AbstractIndexComponent implements Closeable
  • Field Details

    • SINGLE_MAPPING_NAME

      public static final String SINGLE_MAPPING_NAME
      See Also:
    • TYPE_FIELD_NAME

      public static final String TYPE_FIELD_NAME
      See Also:
    • INDEX_MAPPING_NESTED_FIELDS_LIMIT_SETTING

      public static final Setting<Long> INDEX_MAPPING_NESTED_FIELDS_LIMIT_SETTING
    • INDEX_MAPPING_NESTED_DOCS_LIMIT_SETTING

      public static final Setting<Long> INDEX_MAPPING_NESTED_DOCS_LIMIT_SETTING
    • INDEX_MAPPING_TOTAL_FIELDS_LIMIT_SETTING

      public static final Setting<Long> INDEX_MAPPING_TOTAL_FIELDS_LIMIT_SETTING
    • INDEX_MAPPING_DEPTH_LIMIT_SETTING

      public static final Setting<Long> INDEX_MAPPING_DEPTH_LIMIT_SETTING
    • INDEX_MAPPING_FIELD_NAME_LENGTH_LIMIT_SETTING

      public static final Setting<Long> INDEX_MAPPING_FIELD_NAME_LENGTH_LIMIT_SETTING
    • INDEX_MAPPING_DIMENSION_FIELDS_LIMIT_SETTING

      public static final Setting<Long> INDEX_MAPPING_DIMENSION_FIELDS_LIMIT_SETTING
  • Constructor Details

  • Method Details

    • hasNested

      public boolean hasNested()
    • getIndexAnalyzers

      public IndexAnalyzers getIndexAnalyzers()
    • parserContext

      public MappingParserContext parserContext()
    • documentParser

      public DocumentParser documentParser()
      Exposes a DocumentParser
      Returns:
      a document parser to be used to parse incoming documents
    • parseMapping

      public static Map<String,Object> parseMapping(org.elasticsearch.xcontent.NamedXContentRegistry xContentRegistry, String mappingSource) throws IOException
      Parses the mappings (formatted as JSON) into a map
      Throws:
      IOException
    • parseMapping

      public static Map<String,Object> parseMapping(org.elasticsearch.xcontent.NamedXContentRegistry xContentRegistry, CompressedXContent mappingSource) throws IOException
      Parses the mappings (formatted as JSON) into a map
      Throws:
      IOException
    • updateMapping

      public void updateMapping(IndexMetadata currentIndexMetadata, IndexMetadata newIndexMetadata)
      Update local mapping by applying the incoming mapping that have already been merged with the current one on the master
    • merge

      public void merge(IndexMetadata indexMetadata, MapperService.MergeReason reason)
    • merge

      public DocumentMapper merge(String type, CompressedXContent mappingSource, MapperService.MergeReason reason)
    • parseMapping

      public Mapping parseMapping(String mappingType, CompressedXContent mappingSource)
    • mergeMappings

      public static Mapping mergeMappings(DocumentMapper currentMapper, Mapping incomingMapping, MapperService.MergeReason reason)
    • documentMapper

      public DocumentMapper documentMapper()
      Return the document mapper, or null if no mapping has been put yet or no documents have been indexed in the current index yet (which triggers a dynamic mapping update)
    • isMappingSourceTyped

      public static boolean isMappingSourceTyped(String type, Map<String,Object> mapping)
      Returns true if the given mappingSource includes a type as a top-level object.
    • fieldType

      public MappedFieldType fieldType(String fullName)
      Given the full name of a field, returns its MappedFieldType.
    • mappingLookup

      public MappingLookup mappingLookup()
      Exposes a snapshot of the mappings for the current index. If no mappings have been registered for the current index, an empty MappingLookup instance is returned. An index does not have mappings only if it was created without providing mappings explicitly, and no documents have yet been indexed in it.
    • getEagerGlobalOrdinalsFields

      public Iterable<MappedFieldType> getEagerGlobalOrdinalsFields()
      Returns all mapped field types.
    • indexAnalyzer

      public NamedAnalyzer indexAnalyzer(String field, Function<String,NamedAnalyzer> unindexedFieldAnalyzer)
      Return the index-time analyzer associated with a particular field
      Parameters:
      field - the field name
      unindexedFieldAnalyzer - a function to return an Analyzer for a field with no directly associated index-time analyzer
    • close

      public void close() throws IOException
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Throws:
      IOException
    • isMetadataFieldStatic

      @Deprecated public static boolean isMetadataFieldStatic(String fieldName)
      Deprecated.
      Use an instance method isMetadataField instead
      Returns:
      Whether a field is a metadata field Deserialization of SearchHit objects sent from pre 7.8 nodes and GetResults objects sent from pre 7.3 nodes, uses this method to divide fields into meta and document fields. TODO: remove in v 9.0
    • isMetadataField

      public boolean isMetadataField(String field)
      Returns:
      Whether a field is a metadata field. this method considers all mapper plugins
    • reloadSearchAnalyzers

      public List<String> reloadSearchAnalyzers(AnalysisRegistry registry) throws IOException
      Throws:
      IOException