Class FetchContext

java.lang.Object
org.elasticsearch.search.fetch.FetchContext

public class FetchContext extends Object
Encapsulates state required to execute fetch phases
  • Constructor Details

    • FetchContext

      public FetchContext(SearchContext searchContext)
      Create a FetchContext based on a SearchContext
  • Method Details

    • getIndexName

      public String getIndexName()
      The name of the index that documents are being fetched from
    • searcher

      public ContextIndexSearcher searcher()
      The point-in-time searcher the original query was executed against
    • searchLookup

      public SearchLookup searchLookup()
      The SearchLookup for the this context
    • query

      public org.apache.lucene.search.Query query()
      The original query, not rewritten.
    • rewrittenQuery

      public org.apache.lucene.search.Query rewrittenQuery()
      The original query in its rewritten form.
    • parsedQuery

      public ParsedQuery parsedQuery()
      The original query with additional filters and named queries
    • parsedPostFilter

      public ParsedQuery parsedPostFilter()
      Any post-filters run as part of the search
    • fetchSourceContext

      public FetchSourceContext fetchSourceContext()
      Configuration for fetching _source
    • explain

      public boolean explain()
      Should the response include `explain` output
    • rescore

      public List<RescoreContext> rescore()
      The rescorers included in the original search, used for explain output
    • seqNoAndPrimaryTerm

      public boolean seqNoAndPrimaryTerm()
      Should the response include sequence number and primary term metadata
    • docValuesContext

      public FetchDocValuesContext docValuesContext()
      Configuration for fetching docValues fields
    • highlight

      public SearchHighlightContext highlight()
      Configuration for highlighting
    • containsBrokenAnalysis

      public boolean containsBrokenAnalysis(String field)
      Does the index analyzer for this field have token filters that may produce backwards offsets in term vectors
    • fetchScores

      public boolean fetchScores()
      Should the response include scores, even if scores were not calculated in the original query
    • innerHits

      public InnerHitsContext innerHits()
      Configuration for returning inner hits
    • version

      public boolean version()
      Should the response include version metadata
    • fetchFieldsContext

      public FetchFieldsContext fetchFieldsContext()
      Configuration for the 'fields' response
    • scriptFields

      public ScriptFieldsContext scriptFields()
      Configuration for script fields
    • getSearchExt

      public SearchExtBuilder getSearchExt(String name)
      Configuration for external fetch phase plugins
    • getSearchExecutionContext

      public SearchExecutionContext getSearchExecutionContext()
    • getRootSourceLookup

      public SourceLookup getRootSourceLookup(FetchSubPhase.HitContext hitContext)
      For a hit document that's being processed, return the source lookup representing the root document. This method is used to pass down the root source when processing this document's nested inner hits.
      Parameters:
      hitContext - The context of the hit that's being processed.