Package org.elasticsearch.index.mapper
Class MappingLookup
java.lang.Object
org.elasticsearch.index.mapper.MappingLookup
public 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 class
MappingLookup.CacheKey
Key for the lookup to be used in caches. -
Field Summary
Fields Modifier and Type Field Description static MappingLookup
EMPTY
A lookup representing an empty mapping. -
Constructor Summary
Constructors Constructor Description MappingLookup(java.lang.String type, java.util.Collection<FieldMapper> mappers, java.util.Collection<ObjectMapper> objectMappers, java.util.Collection<FieldAliasMapper> aliasMappers, java.util.Collection<RuntimeFieldType> runtimeFieldTypes, int metadataFieldCount, java.util.function.Function<SourceToParse,ParsedDocument> documentParser, boolean sourceEnabled)
-
Method Summary
Modifier and Type Method Description MappingLookup.CacheKey
cacheKey()
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)static MappingLookup
fromMapping(Mapping mapping, java.util.function.Function<SourceToParse,ParsedDocument> documentParser)
MappedFieldType
getFieldType(java.lang.String field)
Returns the mapped field type for the given field name.Mapper
getMapper(java.lang.String field)
Returns the leaf mapper associated with this field name.java.lang.String
getNestedScope(java.lang.String path)
java.lang.String
getType()
boolean
hasMappings()
boolean
hasNested()
NamedAnalyzer
indexAnalyzer(java.lang.String field, java.util.function.Function<java.lang.String,NamedAnalyzer> unmappedFieldAnalyzer)
boolean
isMultiField(java.lang.String field)
boolean
isObjectField(java.lang.String field)
boolean
isSourceEnabled()
java.util.Map<java.lang.String,ObjectMapper>
objectMappers()
ParsedDocument
parseDocument(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.
-
Field Details
-
EMPTY
A lookup representing an empty mapping.
-
-
Constructor Details
-
MappingLookup
public MappingLookup(java.lang.String type, java.util.Collection<FieldMapper> mappers, java.util.Collection<ObjectMapper> objectMappers, java.util.Collection<FieldAliasMapper> aliasMappers, java.util.Collection<RuntimeFieldType> runtimeFieldTypes, int metadataFieldCount, java.util.function.Function<SourceToParse,ParsedDocument> documentParser, boolean sourceEnabled)
-
-
Method Details
-
fromMapping
public static MappingLookup fromMapping(Mapping mapping, java.util.function.Function<SourceToParse,ParsedDocument> documentParser) -
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) -
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()
-