Package org.elasticsearch.index.mapper
Class MapperService
java.lang.Object
org.elasticsearch.index.AbstractIndexComponent
org.elasticsearch.index.mapper.MapperService
- All Implemented Interfaces:
java.io.Closeable,java.lang.AutoCloseable,IndexComponent
public class MapperService extends AbstractIndexComponent implements java.io.Closeable
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classMapperService.MergeReasonThe reason why a mapping is being merged. -
Field Summary
Fields Modifier and Type Field Description static java.lang.StringDEFAULT_MAPPINGstatic booleanINDEX_MAPPER_DYNAMIC_DEFAULTstatic Setting<java.lang.Boolean>INDEX_MAPPER_DYNAMIC_SETTINGDeprecated.static Setting<java.lang.Long>INDEX_MAPPING_DEPTH_LIMIT_SETTINGstatic Setting<java.lang.Long>INDEX_MAPPING_FIELD_NAME_LENGTH_LIMIT_SETTINGstatic Setting<java.lang.Long>INDEX_MAPPING_NESTED_DOCS_LIMIT_SETTINGstatic Setting<java.lang.Long>INDEX_MAPPING_NESTED_FIELDS_LIMIT_SETTINGstatic Setting<java.lang.Long>INDEX_MAPPING_TOTAL_FIELDS_LIMIT_SETTINGstatic java.util.Set<java.lang.String>META_FIELDS_BEFORE_7DOT8Deprecated.static java.lang.StringSINGLE_MAPPING_NAMEFields inherited from class org.elasticsearch.index.AbstractIndexComponent
indexSettings, logger -
Constructor Summary
Constructors Constructor Description MapperService(IndexSettings indexSettings, IndexAnalyzers indexAnalyzers, org.elasticsearch.common.xcontent.NamedXContentRegistry xContentRegistry, SimilarityService similarityService, MapperRegistry mapperRegistry, java.util.function.Supplier<SearchExecutionContext> searchExecutionContextSupplier, java.util.function.BooleanSupplier idFieldDataEnabled, ScriptCompiler scriptCompiler) -
Method Summary
Modifier and Type Method Description voidclose()DocumentMapperdocumentMapper()Return the document mapper, ornullif no mapping has been put yet.DocumentMapperdocumentMapper(java.lang.String type)Return theDocumentMapperfor the given type.DocumentMapperForTypedocumentMapperWithAutoCreate(java.lang.String type)Returns the document mapper created, including a mapping update if the type has been dynamically created.MappedFieldTypefieldType(java.lang.String fullName)Given the full name of a field, returns itsMappedFieldType.java.lang.Iterable<MappedFieldType>getEagerGlobalOrdinalsFields()Returns all mapped field types.IndexAnalyzersgetIndexAnalyzers()NamedAnalyzergetNamedAnalyzer(java.lang.String analyzerName)java.lang.StringgetTypeForUpdate(java.lang.String type, CompressedXContent mappingSource)If the _type name is _doc and there is no _doc top-level key then this means that we are handling a typeless call.booleanhasNested()NamedAnalyzerindexAnalyzer(java.lang.String field, java.util.function.Function<java.lang.String,NamedAnalyzer> unindexedFieldAnalyzer)Return the index-time analyzer associated with a particular fieldstatic booleanisMappingSourceTyped(java.lang.String type, java.util.Map<java.lang.String,java.lang.Object> mapping)Returnstrueif the givenmappingSourceincludes a type as a top-level object.static booleanisMappingSourceTyped(java.lang.String type, CompressedXContent mappingSource)booleanisMetadataField(java.lang.String field)MappingLookupmappingLookup()volatileread a (mostly) immutable snapshot current mapping.voidmerge(java.lang.String type, java.util.Map<java.lang.String,java.lang.Object> mappings, MapperService.MergeReason reason)DocumentMappermerge(java.lang.String type, CompressedXContent mappingSource, MapperService.MergeReason reason)voidmerge(java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.Object>> mappings, MapperService.MergeReason reason)voidmerge(IndexMetadata indexMetadata, MapperService.MergeReason reason)static MappingmergeMappings(DocumentMapper currentMapper, Mapping incomingMapping, MapperService.MergeReason reason)DocumentMapperparse(java.lang.String mappingType, CompressedXContent mappingSource, boolean applyDefault)MappingparseMapping(java.lang.String type, CompressedXContent mappingSource, boolean applyDefault)static java.util.Map<java.lang.String,java.lang.Object>parseMapping(org.elasticsearch.common.xcontent.NamedXContentRegistry xContentRegistry, java.lang.String mappingSource)Parses the mappings (formatted as JSON) into a mapMapper.TypeParser.ParserContextparserContext()java.util.List<java.lang.String>reloadSearchAnalyzers(AnalysisRegistry registry)java.lang.StringresolveDocumentType(java.lang.String type)Resolves a type from a mapping-related request into the type that should be used when merging and updating mappings.java.util.Set<java.lang.String>simpleMatchToFullName(java.lang.String pattern)Returns all the fields that match the given pattern.voidupdateMapping(IndexMetadata currentIndexMetadata, IndexMetadata newIndexMetadata)Update mapping by only merging the metadata that is different between received and stored entriesMethods inherited from class org.elasticsearch.index.AbstractIndexComponent
getIndexSettings, indexMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Field Details
-
DEFAULT_MAPPING
public static final java.lang.String DEFAULT_MAPPING- See Also:
- Constant Field Values
-
SINGLE_MAPPING_NAME
public static final java.lang.String SINGLE_MAPPING_NAME- See Also:
- Constant Field Values
-
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:
- Constant Field Values
-
INDEX_MAPPER_DYNAMIC_SETTING
Deprecated. -
META_FIELDS_BEFORE_7DOT8
@Deprecated public static final java.util.Set<java.lang.String> META_FIELDS_BEFORE_7DOT8Deprecated.
-
-
Constructor Details
-
MapperService
public MapperService(IndexSettings indexSettings, IndexAnalyzers indexAnalyzers, org.elasticsearch.common.xcontent.NamedXContentRegistry xContentRegistry, SimilarityService similarityService, MapperRegistry mapperRegistry, java.util.function.Supplier<SearchExecutionContext> searchExecutionContextSupplier, java.util.function.BooleanSupplier idFieldDataEnabled, ScriptCompiler scriptCompiler)
-
-
Method Details
-
hasNested
public boolean hasNested() -
getIndexAnalyzers
-
getNamedAnalyzer
-
parserContext
-
parseMapping
public static java.util.Map<java.lang.String,java.lang.Object> parseMapping(org.elasticsearch.common.xcontent.NamedXContentRegistry xContentRegistry, java.lang.String mappingSource) throws java.io.IOExceptionParses the mappings (formatted as JSON) into a map- Throws:
java.io.IOException
-
updateMapping
public void updateMapping(IndexMetadata currentIndexMetadata, IndexMetadata newIndexMetadata) throws java.io.IOExceptionUpdate mapping by only merging the metadata that is different between received and stored entries- Throws:
java.io.IOException
-
merge
public void merge(java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.Object>> mappings, MapperService.MergeReason reason) -
merge
public void merge(java.lang.String type, java.util.Map<java.lang.String,java.lang.Object> mappings, MapperService.MergeReason reason) throws java.io.IOException- Throws:
java.io.IOException
-
merge
-
merge
public DocumentMapper merge(java.lang.String type, CompressedXContent mappingSource, MapperService.MergeReason reason) -
parseMapping
public Mapping parseMapping(java.lang.String type, CompressedXContent mappingSource, boolean applyDefault) -
mergeMappings
public static Mapping mergeMappings(DocumentMapper currentMapper, Mapping incomingMapping, MapperService.MergeReason reason) -
parse
public DocumentMapper parse(java.lang.String mappingType, CompressedXContent mappingSource, boolean applyDefault) throws MapperParsingException- Throws:
MapperParsingException
-
documentMapper
Return the document mapper, ornullif no mapping has been put yet. -
documentMapper
Return theDocumentMapperfor the given type. By using the special "_default_" type, you can get aDocumentMapperfor the default mapping. -
isMappingSourceTyped
public static boolean isMappingSourceTyped(java.lang.String type, java.util.Map<java.lang.String,java.lang.Object> mapping)Returnstrueif the givenmappingSourceincludes a type as a top-level object. -
isMappingSourceTyped
public static boolean isMappingSourceTyped(java.lang.String type, CompressedXContent mappingSource) -
getTypeForUpdate
If the _type name is _doc and there is no _doc top-level key then this means that we are handling a typeless call. In such a case, we override _doc with the actual type name in the mappings. This allows to use typeless APIs on typed indices. -
resolveDocumentType
public java.lang.String resolveDocumentType(java.lang.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
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
public java.util.Set<java.lang.String> simpleMatchToFullName(java.lang.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. -
mappingLookup
volatileread a (mostly) immutable snapshot current mapping. -
getEagerGlobalOrdinalsFields
Returns all mapped field types. -
indexAnalyzer
public NamedAnalyzer indexAnalyzer(java.lang.String field, java.util.function.Function<java.lang.String,NamedAnalyzer> unindexedFieldAnalyzer)Return the index-time analyzer associated with a particular field- Parameters:
field- the field nameunindexedFieldAnalyzer- a function to return an Analyzer for a field with no directly associated index-time analyzer
-
close
public void close() throws java.io.IOException- Specified by:
closein interfacejava.lang.AutoCloseable- Specified by:
closein interfacejava.io.Closeable- Throws:
java.io.IOException
-
isMetadataField
public boolean isMetadataField(java.lang.String field)- Returns:
- Whether a field is a metadata field. this method considers all mapper plugins
-
reloadSearchAnalyzers
public java.util.List<java.lang.String> reloadSearchAnalyzers(AnalysisRegistry registry) throws java.io.IOException- Throws:
java.io.IOException
-