Package org.elasticsearch.index.mapper
Class MappingLookup
java.lang.Object
org.elasticsearch.index.mapper.MappingLookup
public final class MappingLookup
extends java.lang.Object
A (mostly) immutable snapshot of the current mapping of an index with
access to everything we need for the search phase.
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classMappingLookup.CacheKeyKey for the lookup to be used in caches. -
Field Summary
Fields Modifier and Type Field Description static MappingLookupEMPTYA lookup representing an empty mapping. -
Constructor Summary
Constructors Constructor Description MappingLookup(Mapping mapping, java.util.Collection<FieldMapper> mappers, java.util.Collection<ObjectMapper> objectMappers, java.util.Collection<FieldAliasMapper> aliasMappers, org.elasticsearch.index.mapper.DocumentParser documentParser, IndexSettings indexSettings, IndexAnalyzers indexAnalyzers) -
Method Summary
Modifier and Type Method Description MappingLookup.CacheKeycacheKey()Key for the lookup to be used in caches.java.lang.Iterable<Mapper>fieldMappers()Returns an iterable over all the registered field mappers (including alias mappers)java.util.Collection<MappedFieldType>fieldTypes()Returns the registered mapped field types.static MappingLookupfromMapping(Mapping mapping, org.elasticsearch.index.mapper.DocumentParser documentParser, IndexSettings indexSettings, IndexAnalyzers indexAnalyzers)MappedFieldTypegetFieldType(java.lang.String field)Returns the mapped field type for the given field name.MappergetMapper(java.lang.String field)Returns the leaf mapper associated with this field name.java.util.List<ObjectMapper>getNestedMappers()Returns all nested object mappersjava.lang.StringgetNestedParent(java.lang.String path)Given a nested object path, returns the path to its nested parent In particular, if a nested field `foo` contains an object field `bar.baz`, then calling this method with `foo.bar.baz` will return the path `foo`, skipping over the object-but-not-nested `foo.bar`java.util.List<ObjectMapper>getNestedParentMappers()Returns all nested object mappers which contain further nested object mappers Used by BitSetProducerWarmerjava.lang.StringgetNestedScope(java.lang.String path)java.lang.StringgetType()booleanhasMappings()booleanhasNested()booleanhasNonNestedParent(java.lang.String path)Given an object path, checks to see if any of its parents are non-nested objectsNamedAnalyzerindexAnalyzer(java.lang.String field, java.util.function.Function<java.lang.String,NamedAnalyzer> unmappedFieldAnalyzer)booleanisMultiField(java.lang.String field)booleanisObjectField(java.lang.String field)booleanisSourceEnabled()java.util.Map<java.lang.String,ObjectMapper>objectMappers()ParsedDocumentparseDocument(SourceToParse source)java.util.Set<java.lang.String>simpleMatchToFullName(java.lang.String pattern)java.util.Set<java.lang.String>sourcePaths(java.lang.String field)Given a concrete field name, return its paths in the _source.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Field Details
-
EMPTY
A lookup representing an empty mapping.
-
-
Constructor Details
-
MappingLookup
public MappingLookup(Mapping mapping, java.util.Collection<FieldMapper> mappers, java.util.Collection<ObjectMapper> objectMappers, java.util.Collection<FieldAliasMapper> aliasMappers, org.elasticsearch.index.mapper.DocumentParser documentParser, IndexSettings indexSettings, IndexAnalyzers indexAnalyzers)
-
-
Method Details
-
fromMapping
public static MappingLookup fromMapping(Mapping mapping, org.elasticsearch.index.mapper.DocumentParser documentParser, IndexSettings indexSettings, IndexAnalyzers indexAnalyzers) -
getMapper
Returns the leaf mapper associated with this field name. Note that the returned mapper could be either a concreteFieldMapper, or aFieldAliasMapper. To access a field's type information,MapperService.fieldType(java.lang.String)should be used instead. -
indexAnalyzer
public NamedAnalyzer indexAnalyzer(java.lang.String field, java.util.function.Function<java.lang.String,NamedAnalyzer> unmappedFieldAnalyzer) -
fieldMappers
Returns an iterable over all the registered field mappers (including alias mappers) -
fieldTypes
Returns the registered mapped field types. -
hasNested
public boolean hasNested() -
objectMappers
-
isMultiField
public boolean isMultiField(java.lang.String field) -
isObjectField
public boolean isObjectField(java.lang.String field) -
getNestedScope
public java.lang.String getNestedScope(java.lang.String path) -
simpleMatchToFullName
public java.util.Set<java.lang.String> simpleMatchToFullName(java.lang.String pattern) -
getFieldType
Returns the mapped field type for the given field name. -
sourcePaths
public java.util.Set<java.lang.String> sourcePaths(java.lang.String field)Given a concrete field name, return its paths in the _source. For most fields, the source path is the same as the field itself. However there are cases where a field's values are found elsewhere in the _source: - For a multi-field, the source path is the parent field. - One field's content could have been copied to another through copy_to.- Parameters:
field- The field for which to look up the _source path. Note that the field should be a concrete field and *not* an alias.- Returns:
- A set of paths in the _source that contain the field's values.
-
parseDocument
-
hasMappings
public boolean hasMappings() -
isSourceEnabled
public boolean isSourceEnabled() -
cacheKey
Key for the lookup to be used in caches. -
getType
public java.lang.String getType() -
hasNonNestedParent
public boolean hasNonNestedParent(java.lang.String path)Given an object path, checks to see if any of its parents are non-nested objects -
getNestedMappers
Returns all nested object mappers -
getNestedParentMappers
Returns all nested object mappers which contain further nested object mappers Used by BitSetProducerWarmer -
getNestedParent
public java.lang.String getNestedParent(java.lang.String path)Given a nested object path, returns the path to its nested parent In particular, if a nested field `foo` contains an object field `bar.baz`, then calling this method with `foo.bar.baz` will return the path `foo`, skipping over the object-but-not-nested `foo.bar`
-