Class MapperService

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

@PublicApi(since="1.0.0") public class MapperService extends AbstractIndexComponent implements Closeable
The core field mapping service
Opensearch.api:
  • Field Details

    • SINGLE_MAPPING_NAME

      public static final String SINGLE_MAPPING_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_MAPPER_DYNAMIC_DEFAULT

      public static final boolean INDEX_MAPPER_DYNAMIC_DEFAULT
      See Also:
    • INDEX_MAPPER_DYNAMIC_SETTING

      @Deprecated public static final Setting<Boolean> INDEX_MAPPER_DYNAMIC_SETTING
      Deprecated.
    • META_FIELDS_BEFORE_7DOT8

      @Deprecated public static final Set<String> META_FIELDS_BEFORE_7DOT8
      Deprecated.
  • Constructor Details

  • Method Details

    • hasNested

      public boolean hasNested()
    • getIndexAnalyzers

      public IndexAnalyzers getIndexAnalyzers()
    • getNamedAnalyzer

      public NamedAnalyzer getNamedAnalyzer(String analyzerName)
    • documentMapperParser

      public DocumentMapperParser documentMapperParser()
    • parseMapping

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

      public boolean updateMapping(IndexMetadata currentIndexMetadata, IndexMetadata newIndexMetadata) throws IOException
      Update mapping by only merging the metadata that is different between received and stored entries
      Throws:
      IOException
    • merge

      public void merge(Map<String,Map<String,Object>> mappings, MapperService.MergeReason reason)
    • merge

      public void merge(String type, Map<String,Object> mappings, MapperService.MergeReason reason) throws IOException
      Throws:
      IOException
    • merge

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

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

      public DocumentMapper parse(String mappingType, CompressedXContent mappingSource) throws MapperParsingException
      Throws:
      MapperParsingException
    • documentMapper

      public DocumentMapper documentMapper()
      Return the document mapper, or null if no mapping has been put yet.
    • 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.
    • isMappingSourceTyped

      public static boolean isMappingSourceTyped(String type, CompressedXContent mappingSource)
    • resolveDocumentType

      public String resolveDocumentType(String type)
      Resolves a type from a mapping-related request into the type that should be used when merging and updating mappings.

      If the special `_doc` type is provided, then we replace it with the actual type that is being used in the mappings. This allows typeless APIs such as 'index' or 'put mappings' to work against indices with a custom type name.

    • documentMapperWithAutoCreate

      public DocumentMapperForType documentMapperWithAutoCreate()
      Returns the document mapper created, including a mapping update if the type has been dynamically created.
    • fieldType

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

      public Set<String> simpleMatchToFullName(String pattern)
      Returns all the fields that match the given pattern. If the pattern is prefixed with a type then the fields will be returned with a type prefix.
    • sourcePath

      public Set<String> sourcePath(String fullName)
      Given a field name, returns its possible paths in the _source. For example, the 'source path' for a multi-field is the path to its parent field.
    • fieldTypes

      public Iterable<MappedFieldType> fieldTypes()
      Returns all mapped field types.
    • isCompositeIndexPresent

      public boolean isCompositeIndexPresent()
    • getCompositeFieldTypes

      public Set<CompositeMappedFieldType> getCompositeFieldTypes()
    • isFieldPartOfCompositeIndex

      public boolean isFieldPartOfCompositeIndex(String field)
    • getObjectMapper

      public ObjectMapper getObjectMapper(String name)
    • unmappedFieldType

      public MappedFieldType unmappedFieldType(String type)
      Given a type (eg. long, string, ...), return an anonymous field mapper that can be used for search operations.
    • indexAnalyzer

      public org.apache.lucene.analysis.Analyzer indexAnalyzer()
    • searchAnalyzer

      public org.apache.lucene.analysis.Analyzer searchAnalyzer()
    • searchQuoteAnalyzer

      public org.apache.lucene.analysis.Analyzer searchQuoteAnalyzer()
    • isIdFieldDataEnabled

      public boolean isIdFieldDataEnabled()
      Returns true if fielddata is enabled for the IdFieldMapper field, false otherwise.
    • close

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

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

      public Set<String> getMetadataFields()
      Returns a set containing the registered metadata fields
    • reloadSearchAnalyzers

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