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_SETTINGstatic Setting<java.lang.Long>INDEX_MAPPING_DEPTH_LIMIT_SETTINGstatic Setting<java.lang.Long>INDEX_MAPPING_NESTED_FIELDS_LIMIT_SETTINGstatic Setting<java.lang.Long>INDEX_MAPPING_TOTAL_FIELDS_LIMIT_SETTINGstatic java.lang.StringSINGLE_MAPPING_NAME-
Fields inherited from class org.elasticsearch.index.AbstractIndexComponent
deprecationLogger, indexSettings, logger
-
-
Constructor Summary
Constructors Constructor Description MapperService(IndexSettings indexSettings, IndexAnalyzers indexAnalyzers, NamedXContentRegistry xContentRegistry, SimilarityService similarityService, MapperRegistry mapperRegistry, java.util.function.Supplier<QueryShardContext> queryShardContextSupplier)
-
Method Summary
Modifier and Type Method Description booleanallEnabled()Returns true if the "_all" field is enabled on any type.voidclose()org.apache.lucene.index.TermcreateUidTerm(java.lang.String type, java.lang.String id)Return a term that uniquely identifies the document, ornullif the type is not allowed.java.lang.Iterable<DocumentMapper>docMappers(boolean includingDefaultMapping)returns an immutable iterator over current document mappers.DocumentMapperdocumentMapper(java.lang.String type)Return theDocumentMapperfor the given type.DocumentMapperParserdocumentMapperParser()DocumentMapperForTypedocumentMapperWithAutoCreate(java.lang.String type)Returns the document mapper created, including a mapping update if the type has been dynamically created.java.lang.Iterable<MappedFieldType>fieldTypes()Returns all mapped field types.MappedFieldTypefullName(java.lang.String fullName)Returns theMappedFieldTypefor the give fullName.static java.lang.String[]getAllMetaFields()IndexAnalyzersgetIndexAnalyzers()NamedAnalyzergetNamedAnalyzer(java.lang.String analyzerName)ObjectMappergetObjectMapper(java.lang.String name)java.util.Set<java.lang.String>getParentTypes()booleanhasMapping(java.lang.String mappingType)booleanhasNested()org.apache.lucene.analysis.AnalyzerindexAnalyzer()static 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)static booleanisMetadataField(java.lang.String fieldName)DocumentMappermerge(java.lang.String type, CompressedXContent mappingSource, MapperService.MergeReason reason, boolean updateAllTypes)voidmerge(java.util.Map<java.lang.String,java.util.Map<java.lang.String,java.lang.Object>> mappings, MapperService.MergeReason reason, boolean updateAllTypes)voidmerge(IndexMetaData indexMetaData, MapperService.MergeReason reason, boolean updateAllTypes)DocumentMapperparse(java.lang.String mappingType, CompressedXContent mappingSource, boolean applyDefault)static java.util.Map<java.lang.String,java.lang.Object>parseMapping(NamedXContentRegistry xContentRegistry, java.lang.String mappingSource)Parses the mappings (formatted as JSON) into a mapjava.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.org.apache.lucene.analysis.AnalyzersearchAnalyzer()org.apache.lucene.analysis.AnalyzersearchQuoteAnalyzer()java.util.Collection<java.lang.String>simpleMatchToFullName(java.lang.String pattern)Returns all the fields that match the given pattern.java.util.Collection<java.lang.String>types()Return the set of concrete types that have a mapping.MappedFieldTypeunmappedFieldType(java.lang.String type)Given a type (eg.booleanupdateMapping(IndexMetaData currentIndexMetaData, IndexMetaData newIndexMetaData)Update mapping by only merging the metadata that is different between received and stored entries-
Methods inherited from class org.elasticsearch.index.AbstractIndexComponent
getIndexSettings, index
-
-
-
-
Field Detail
-
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
public static final Setting<java.lang.Long> INDEX_MAPPING_NESTED_FIELDS_LIMIT_SETTING
-
INDEX_MAPPING_TOTAL_FIELDS_LIMIT_SETTING
public static final Setting<java.lang.Long> INDEX_MAPPING_TOTAL_FIELDS_LIMIT_SETTING
-
INDEX_MAPPING_DEPTH_LIMIT_SETTING
public static final Setting<java.lang.Long> INDEX_MAPPING_DEPTH_LIMIT_SETTING
-
INDEX_MAPPER_DYNAMIC_DEFAULT
public static final boolean INDEX_MAPPER_DYNAMIC_DEFAULT
- See Also:
- Constant Field Values
-
INDEX_MAPPER_DYNAMIC_SETTING
public static final Setting<java.lang.Boolean> INDEX_MAPPER_DYNAMIC_SETTING
-
-
Constructor Detail
-
MapperService
public MapperService(IndexSettings indexSettings, IndexAnalyzers indexAnalyzers, NamedXContentRegistry xContentRegistry, SimilarityService similarityService, MapperRegistry mapperRegistry, java.util.function.Supplier<QueryShardContext> queryShardContextSupplier)
-
-
Method Detail
-
hasNested
public boolean hasNested()
-
allEnabled
public boolean allEnabled()
Returns true if the "_all" field is enabled on any type.
-
docMappers
public java.lang.Iterable<DocumentMapper> docMappers(boolean includingDefaultMapping)
returns an immutable iterator over current document mappers.- Parameters:
includingDefaultMapping- indicates whether the iterator should contain theDEFAULT_MAPPINGdocument mapper. As is this not really an active type, you would typically set this to false
-
getIndexAnalyzers
public IndexAnalyzers getIndexAnalyzers()
-
getNamedAnalyzer
public NamedAnalyzer getNamedAnalyzer(java.lang.String analyzerName)
-
documentMapperParser
public DocumentMapperParser documentMapperParser()
-
parseMapping
public static java.util.Map<java.lang.String,java.lang.Object> parseMapping(NamedXContentRegistry xContentRegistry, java.lang.String mappingSource) throws java.lang.Exception
Parses the mappings (formatted as JSON) into a map- Throws:
java.lang.Exception
-
updateMapping
public boolean updateMapping(IndexMetaData currentIndexMetaData, IndexMetaData newIndexMetaData) throws java.io.IOException
Update 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, boolean updateAllTypes)
-
merge
public void merge(IndexMetaData indexMetaData, MapperService.MergeReason reason, boolean updateAllTypes)
-
merge
public DocumentMapper merge(java.lang.String type, CompressedXContent mappingSource, MapperService.MergeReason reason, boolean updateAllTypes)
-
parse
public DocumentMapper parse(java.lang.String mappingType, CompressedXContent mappingSource, boolean applyDefault) throws MapperParsingException
- Throws:
MapperParsingException
-
hasMapping
public boolean hasMapping(java.lang.String mappingType)
-
types
public java.util.Collection<java.lang.String> types()
Return the set of concrete types that have a mapping. NOTE: this does not return the default mapping.
-
documentMapper
public DocumentMapper documentMapper(java.lang.String type)
Return theDocumentMapperfor the given type. By using the special "_default_" type, you can get aDocumentMapperfor the default mapping.
-
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
public DocumentMapperForType documentMapperWithAutoCreate(java.lang.String type)
Returns the document mapper created, including a mapping update if the type has been dynamically created.
-
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)
-
fullName
public MappedFieldType fullName(java.lang.String fullName)
Returns theMappedFieldTypefor the give fullName. If multiple types have fields with the same full name, the first is returned.
-
simpleMatchToFullName
public java.util.Collection<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.
-
fieldTypes
public java.lang.Iterable<MappedFieldType> fieldTypes()
Returns all mapped field types.
-
getObjectMapper
public ObjectMapper getObjectMapper(java.lang.String name)
-
unmappedFieldType
public MappedFieldType unmappedFieldType(java.lang.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()
-
getParentTypes
public java.util.Set<java.lang.String> getParentTypes()
-
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 static boolean isMetadataField(java.lang.String fieldName)
- Returns:
- Whether a field is a metadata field.
-
getAllMetaFields
public static java.lang.String[] getAllMetaFields()
-
createUidTerm
public org.apache.lucene.index.Term createUidTerm(java.lang.String type, java.lang.String id)Return a term that uniquely identifies the document, ornullif the type is not allowed.
-
-