Class MappingLookup

org.elasticsearch.index.mapper.MappingLookup

public final class MappingLookup extends
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 
    Key for the lookup to be used in caches.
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    A lookup representing an empty mapping.
  • Method Summary

    Modifier and Type
    Method
    Description
    Key for the lookup to be used in caches.
    Returns an iterable over all the registered field mappers (including alias mappers)
    fromMappers​(Mapping mapping, <FieldMapper> mappers, <ObjectMapper> objectMappers, <FieldAliasMapper> aliasMappers)
    Creates a new MappingLookup instance given the provided mappers and mapping.
    fromMapping​(Mapping mapping)
    Creates a new MappingLookup instance by parsing the provided mapping and extracting its field definitions.
     field)
    Returns the mapped field type for the given field name.
     field)
    Returns the leaf mapper associated with this field name.
    Returns the mapping source that this lookup originated from
    <>
     pattern)
    Returns a set of field names that match a regex-like pattern All field names in the returned set are guaranteed to resolve to a field
    Returns all nested object mappers
     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`
    Returns all nested object mappers which contain further nested object mappers Used by BitSetProducerWarmer
     path)
     
     
    boolean
    Returns true if the index has mappings.
    boolean
     
     field, <,​NamedAnalyzer> unmappedFieldAnalyzer)
     
    boolean
     field)
     
    boolean
     field)
     
    boolean
     
     
    <>
     field)
    Given a concrete field name, return its paths in the _source.

    Methods inherited from class java.lang.

    , , , , , , , , , ,
  • Field Details

  • Method Details

    • fromMapping

      public static MappingLookup fromMapping(Mapping mapping)
      Creates a new MappingLookup instance by parsing the provided mapping and extracting its field definitions.
      Parameters:
      mapping - the mapping source
      Returns:
      the newly created lookup instance
    • fromMappers

      public static MappingLookup fromMappers(Mapping mapping, <FieldMapper> mappers, <ObjectMapper> objectMappers, <FieldAliasMapper> aliasMappers)
      Creates a new MappingLookup instance given the provided mappers and mapping. Note that the provided mappings are not re-parsed but only exposed as-is. No consistency is enforced between the provided mappings and set of mappers. This is a commodity method to be used in tests, or whenever no mappings are defined for an index. When creating a MappingLookup through this method, its exposed functionalities are limited as it does not hold a valid DocumentParser, IndexSettings or IndexAnalyzers.
      Parameters:
      mapping - the mapping
      mappers - the field mappers
      objectMappers - the object mappers
      aliasMappers - the field alias mappers
      Returns:
      the newly created lookup instance
    • getMapper

      public  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  field, <,​NamedAnalyzer> unmappedFieldAnalyzer)
    • fieldMappers

      public <Mapper> fieldMappers()
      Returns an iterable over all the registered field mappers (including alias mappers)
    • hasNested

      public boolean hasNested()
    • objectMappers

      public <,​ObjectMapper> objectMappers()
    • isMultiField

      public boolean isMultiField( field)
    • isObjectField

      public boolean isObjectField( field)
    • getNestedScope

      public  getNestedScope( path)
    • getMatchingFieldNames

      public <> getMatchingFieldNames( pattern)
      Returns a set of field names that match a regex-like pattern All field names in the returned set are guaranteed to resolve to a field
      Parameters:
      pattern - the pattern to match field names against
    • getFieldType

      public  field)
      Returns the mapped field type for the given field name.
    • sourcePaths

      public <> sourcePaths( 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.
    • hasMappings

      public boolean hasMappings()
      Returns true if the index has mappings. An index does not have mappings only if it was created without providing mappings explicitly, and no documents have yet been indexed in it.
      Returns:
      true if the current index has mappings, false otherwise
    • isSourceEnabled

      public boolean isSourceEnabled()
    • cacheKey

      public MappingLookup.CacheKey cacheKey()
      Key for the lookup to be used in caches.
    • getType

      public  getType()
    • getMapping

      public Mapping getMapping()
      Returns the mapping source that this lookup originated from
      Returns:
      the mapping source
    • getNestedMappers

      public <ObjectMapper> getNestedMappers()
      Returns all nested object mappers
    • getNestedParentMappers

      public <ObjectMapper> getNestedParentMappers()
      Returns all nested object mappers which contain further nested object mappers Used by BitSetProducerWarmer
    • getNestedParent

      public  getNestedParent( 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`