Class ReaderContext

java.lang.Object
org.elasticsearch.search.internal.ReaderContext
All Implemented Interfaces:
Closeable, AutoCloseable, org.elasticsearch.core.Releasable
Direct Known Subclasses:
LegacyReaderContext

public class ReaderContext extends Object implements org.elasticsearch.core.Releasable
Holds a reference to a point in time Engine.Searcher that will be used to construct SearchContext. This class also implements RefCounted since in some situations like in SearchService a SearchContext can be closed concurrently due to independent events ie. when an index gets removed. To prevent accessing closed IndexReader / IndexSearcher instances the SearchContext can be guarded by a reference count and fail if it's been closed by an external event.
  • Field Details

  • Constructor Details

  • Method Details

    • validate

      public void validate(TransportRequest request)
    • close

      public final void close()
      Specified by:
      close in interface AutoCloseable
      Specified by:
      close in interface Closeable
      Specified by:
      close in interface org.elasticsearch.core.Releasable
    • addOnClose

      public void addOnClose(org.elasticsearch.core.Releasable releasable)
    • id

      public ShardSearchContextId id()
    • indexService

      public IndexService indexService()
    • indexShard

      public IndexShard indexShard()
    • acquireSearcher

      public Engine.Searcher acquireSearcher(String source)
    • markAsUsed

      public org.elasticsearch.core.Releasable markAsUsed(long keepAliveInMillis)
      Returns a releasable to indicate that the caller has stopped using this reader. The time to live of the reader after usage can be extended using the provided keepAliveInMillis.
    • isExpired

      public boolean isExpired()
    • getShardSearchRequest

      public ShardSearchRequest getShardSearchRequest(ShardSearchRequest other)
    • scrollContext

      public ScrollContext scrollContext()
    • getAggregatedDfs

      public AggregatedDfs getAggregatedDfs(AggregatedDfs other)
    • setAggregatedDfs

      public void setAggregatedDfs(AggregatedDfs aggregatedDfs)
    • getRescoreDocIds

      public RescoreDocIds getRescoreDocIds(RescoreDocIds other)
    • setRescoreDocIds

      public void setRescoreDocIds(RescoreDocIds rescoreDocIds)
    • singleSession

      public boolean singleSession()
      Returns true for readers that are intended to use in a single query. For readers that are intended to use in multiple queries (i.e., scroll or readers), we should not release them after the fetch phase or the query phase with empty results.
    • getFromContext

      public <T> T getFromContext(String key)
      Returns the object or null if the given key does not have a value in the context
    • putInContext

      public void putInContext(String key, Object value)
      Puts the object into the context
    • getStartTimeInNano

      public long getStartTimeInNano()