Class SearchContext

java.lang.Object
org.elasticsearch.common.util.concurrent.AbstractRefCounted
org.elasticsearch.search.internal.SearchContext
All Implemented Interfaces:
java.io.Closeable, java.lang.AutoCloseable, Releasable, RefCounted
Direct Known Subclasses:
FilteredSearchContext

public abstract class SearchContext
extends AbstractRefCounted
implements Releasable
This class encapsulates the state needed to execute a search. It holds a reference to the shards point in time snapshot (IndexReader / ContextIndexSearcher) and allows passing on state from one query / fetch phase to another. 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.