Package org.opensearch.index.mapper
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:
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic enum
The reason why a mapping is being merged. -
Field Summary
Modifier and TypeFieldDescriptionstatic final boolean
Deprecated.Deprecated.static final String
Fields inherited from class org.opensearch.index.AbstractIndexComponent
indexSettings, logger
-
Constructor Summary
ConstructorDescriptionMapperService
(IndexSettings indexSettings, IndexAnalyzers indexAnalyzers, org.opensearch.core.xcontent.NamedXContentRegistry xContentRegistry, SimilarityService similarityService, MapperRegistry mapperRegistry, Supplier<QueryShardContext> queryShardContextSupplier, BooleanSupplier idFieldDataEnabled, ScriptService scriptService) -
Method Summary
Modifier and TypeMethodDescriptionvoid
close()
Return the document mapper, ornull
if no mapping has been put yet.Returns the document mapper created, including a mapping update if the type has been dynamically created.Given the full name of a field, returns itsMappedFieldType
.Returns all mapped field types.Returns a set containing the registered metadata fieldsgetNamedAnalyzer
(String analyzerName) getObjectMapper
(String name) boolean
org.apache.lucene.analysis.Analyzer
boolean
boolean
boolean
static boolean
isMappingSourceTyped
(String type, Map<String, Object> mapping) Returnstrue
if the givenmappingSource
includes a type as a top-level object.static boolean
isMappingSourceTyped
(String type, CompressedXContent mappingSource) boolean
isMetadataField
(String field) void
merge
(String type, CompressedXContent mappingSource, MapperService.MergeReason reason) void
void
merge
(IndexMetadata indexMetadata, MapperService.MergeReason reason) parse
(String mappingType, CompressedXContent mappingSource) parseMapping
(org.opensearch.core.xcontent.NamedXContentRegistry xContentRegistry, String mappingSource) Parses the mappings (formatted as JSON) into a mapreloadSearchAnalyzers
(AnalysisRegistry registry) resolveDocumentType
(String type) Resolves a type from a mapping-related request into the type that should be used when merging and updating mappings.org.apache.lucene.analysis.Analyzer
org.apache.lucene.analysis.Analyzer
simpleMatchToFullName
(String pattern) Returns all the fields that match the given pattern.sourcePath
(String fullName) Given a field name, returns its possible paths in the _source.unmappedFieldType
(String type) Given a type (eg.boolean
updateMapping
(IndexMetadata currentIndexMetadata, IndexMetadata newIndexMetadata) Update mapping by only merging the metadata that is different between received and stored entriesMethods inherited from class org.opensearch.index.AbstractIndexComponent
getIndexSettings, index
-
Field Details
-
SINGLE_MAPPING_NAME
- See Also:
-
INDEX_MAPPING_NESTED_FIELDS_LIMIT_SETTING
-
INDEX_MAPPING_NESTED_DOCS_LIMIT_SETTING
-
INDEX_MAPPING_TOTAL_FIELDS_LIMIT_SETTING
-
INDEX_MAPPING_DEPTH_LIMIT_SETTING
-
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. -
META_FIELDS_BEFORE_7DOT8
Deprecated.
-
-
Constructor Details
-
MapperService
public MapperService(IndexSettings indexSettings, IndexAnalyzers indexAnalyzers, org.opensearch.core.xcontent.NamedXContentRegistry xContentRegistry, SimilarityService similarityService, MapperRegistry mapperRegistry, Supplier<QueryShardContext> queryShardContextSupplier, BooleanSupplier idFieldDataEnabled, ScriptService scriptService)
-
-
Method Details
-
hasNested
public boolean hasNested() -
getIndexAnalyzers
-
getNamedAnalyzer
-
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
-
merge
public void merge(String type, Map<String, Object> mappings, MapperService.MergeReason reason) throws IOException- Throws:
IOException
-
merge
-
merge
public DocumentMapper merge(String type, CompressedXContent mappingSource, MapperService.MergeReason reason) -
parse
public DocumentMapper parse(String mappingType, CompressedXContent mappingSource) throws MapperParsingException - Throws:
MapperParsingException
-
documentMapper
Return the document mapper, ornull
if no mapping has been put yet. -
isMappingSourceTyped
Returnstrue
if the givenmappingSource
includes a type as a top-level object. -
isMappingSourceTyped
-
resolveDocumentType
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
Returns the document mapper created, including a mapping update if the type has been dynamically created. -
fieldType
Given the full name of a field, returns itsMappedFieldType
. -
simpleMatchToFullName
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
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
Returns all mapped field types. -
isCompositeIndexPresent
public boolean isCompositeIndexPresent() -
getCompositeFieldTypes
-
isFieldPartOfCompositeIndex
-
getObjectMapper
-
unmappedFieldType
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() -
close
- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceCloseable
- Throws:
IOException
-
isMetadataField
- Returns:
- Whether a field is a metadata field. this method considers all mapper plugins
-
getMetadataFields
Returns a set containing the registered metadata fields -
reloadSearchAnalyzers
- Throws:
IOException
-