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.
  • Field Details

    • EMPTY

      public static final MappingLookup EMPTY
      A lookup representing an empty mapping.
  • Constructor Details

  • Method Details

    • fromMapping

      public static MappingLookup fromMapping​(Mapping mapping, org.elasticsearch.index.mapper.DocumentParser documentParser, IndexSettings indexSettings, IndexAnalyzers indexAnalyzers)
    • getMapper

      public Mapper getMapper​(java.lang.String field)
      Returns the leaf mapper associated with this field name. Note that the returned mapper could be either a concrete FieldMapper, or a FieldAliasMapper. 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

      public java.lang.Iterable<Mapper> fieldMappers()
      Returns an iterable over all the registered field mappers (including alias mappers)
    • fieldTypes

      public java.util.Collection<MappedFieldType> fieldTypes()
      Returns the registered mapped field types.
    • hasNested

      public boolean hasNested()
    • objectMappers

      public java.util.Map<java.lang.String,​ObjectMapper> 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

      public MappedFieldType getFieldType​(java.lang.String field)
      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

      public ParsedDocument parseDocument​(SourceToParse source)
    • hasMappings

      public boolean hasMappings()
    • isSourceEnabled

      public boolean isSourceEnabled()
    • cacheKey

      public MappingLookup.CacheKey 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

      public java.util.List<ObjectMapper> getNestedMappers()
      Returns all nested object mappers
    • getNestedParentMappers

      public java.util.List<ObjectMapper> 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`