Class SearchLookup

java.lang.Object
org.elasticsearch.search.lookup.SearchLookup
All Implemented Interfaces:
SourceProvider

public class SearchLookup extends Object implements SourceProvider
Provides a way to look up per-document values from docvalues, stored fields or _source
  • Constructor Details

  • Method Details

    • forkAndTrackFieldReferences

      public final SearchLookup forkAndTrackFieldReferences(String field)
      Creates a copy of the current SearchLookup that looks fields up in the same way, but also tracks field references in order to detect cycles and prevent resolving fields that depend on more than MAX_FIELD_CHAIN_DEPTH other fields.
      Parameters:
      field - the field being referred to, for which fielddata needs to be loaded
      Returns:
      the new lookup
      Throws:
      IllegalArgumentException - if a cycle is detected in the fields required to build doc values, or if the field being resolved depends on more than MAX_FIELD_CHAIN_DEPTH
    • getLeafSearchLookup

      public LeafSearchLookup getLeafSearchLookup(org.apache.lucene.index.LeafReaderContext context)
    • fieldType

      public MappedFieldType fieldType(String fieldName)
    • onlyMappedAsRuntimeField

      public boolean onlyMappedAsRuntimeField(String fieldName)
      Returns:
      whether a field is only mapped as runtime field. A runtime and normal field can share the same name.
    • getForField

      public IndexFieldData<?> getForField(MappedFieldType fieldType, MappedFieldType.FielddataOperation options)
    • getSource

      public Source getSource(org.apache.lucene.index.LeafReaderContext ctx, int doc) throws IOException
      Description copied from interface: SourceProvider
      Get the Source for the given doc within the given context
      Specified by:
      getSource in interface SourceProvider
      Throws:
      IOException
    • optimizedSourceProvider

      public SearchLookup optimizedSourceProvider(SourceFilter sourceFilter)
      Description copied from interface: SourceProvider
      Optionally returns a new SourceProvider that is more optimized to load source with the provided source filter in mind.

      Currently this is only the case if source mode is synthetic, and only a subset of fields is requested, then only loading source for requested fields is much more efficient.

      Specified by:
      optimizedSourceProvider in interface SourceProvider
      Parameters:
      sourceFilter - The part of the source the caller is actually interested in.
      Returns:
      a new instance if source can be loaded in a more optimal way, otherwise returns this instance.