Package org.elasticsearch.search
Class SearchService
java.lang.Object
org.elasticsearch.common.component.AbstractLifecycleComponent
org.elasticsearch.search.SearchService
- All Implemented Interfaces:
java.io.Closeable
,java.lang.AutoCloseable
,LifecycleComponent
,Releasable
,IndexEventListener
public class SearchService extends AbstractLifecycleComponent implements IndexEventListener
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static class
SearchService.CanMatchResponse
-
Field Summary
Fields Modifier and Type Field Description static Setting<java.lang.Boolean>
ALLOW_EXPENSIVE_QUERIES
static Setting<java.lang.Boolean>
DEFAULT_ALLOW_PARTIAL_SEARCH_RESULTS
static int
DEFAULT_FROM
static Setting<TimeValue>
DEFAULT_KEEPALIVE_SETTING
static Setting<TimeValue>
DEFAULT_SEARCH_TIMEOUT_SETTING
static int
DEFAULT_SIZE
static Setting<TimeValue>
KEEPALIVE_INTERVAL_SETTING
static Setting<java.lang.Boolean>
LOW_LEVEL_CANCELLATION_SETTING
Enables low-level, frequent search cancellation checks.static Setting<TimeValue>
MAX_KEEPALIVE_SETTING
static Setting<java.lang.Integer>
MAX_OPEN_SCROLL_CONTEXT
static TimeValue
NO_TIMEOUT
-
Constructor Summary
Constructors Constructor Description SearchService(ClusterService clusterService, IndicesService indicesService, ThreadPool threadPool, ScriptService scriptService, BigArrays bigArrays, FetchPhase fetchPhase, ResponseCollectorService responseCollectorService, CircuitBreakerService circuitBreakerService)
-
Method Summary
Methods inherited from class org.elasticsearch.common.component.AbstractLifecycleComponent
addLifecycleListener, close, lifecycleState, removeLifecycleListener, start, stop
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.elasticsearch.index.shard.IndexEventListener
afterIndexCreated, afterIndexShardClosed, afterIndexShardCreated, afterIndexShardDeleted, afterIndexShardStarted, beforeIndexAddedToCluster, beforeIndexCreated, beforeIndexRemoved, beforeIndexShardClosed, beforeIndexShardCreated, beforeIndexShardDeleted, indexShardStateChanged, onShardInactive, onStoreClosed, onStoreCreated, shardRoutingChanged
-
Field Details
-
DEFAULT_KEEPALIVE_SETTING
-
MAX_KEEPALIVE_SETTING
-
KEEPALIVE_INTERVAL_SETTING
-
ALLOW_EXPENSIVE_QUERIES
-
LOW_LEVEL_CANCELLATION_SETTING
Enables low-level, frequent search cancellation checks. Enabling low-level checks will make long running searches to react to the cancellation request faster. It will produce more cancellation checks but benchmarking has shown these did not noticeably slow down searches. -
NO_TIMEOUT
-
DEFAULT_SEARCH_TIMEOUT_SETTING
-
DEFAULT_ALLOW_PARTIAL_SEARCH_RESULTS
-
MAX_OPEN_SCROLL_CONTEXT
-
DEFAULT_SIZE
public static final int DEFAULT_SIZE- See Also:
- Constant Field Values
-
DEFAULT_FROM
public static final int DEFAULT_FROM- See Also:
- Constant Field Values
-
-
Constructor Details
-
SearchService
public SearchService(ClusterService clusterService, IndicesService indicesService, ThreadPool threadPool, ScriptService scriptService, BigArrays bigArrays, FetchPhase fetchPhase, ResponseCollectorService responseCollectorService, CircuitBreakerService circuitBreakerService)
-
-
Method Details
-
defaultAllowPartialSearchResults
public boolean defaultAllowPartialSearchResults() -
afterIndexRemoved
public void afterIndexRemoved(Index index, IndexSettings indexSettings, IndicesClusterStateService.AllocatedIndices.IndexRemovalReason reason)Description copied from interface:IndexEventListener
Called after the index has been removed.- Specified by:
afterIndexRemoved
in interfaceIndexEventListener
- Parameters:
index
- The indexreason
- the reason for index removal
-
putContext
-
removeContext
-
doStart
protected void doStart()- Specified by:
doStart
in classAbstractLifecycleComponent
-
doStop
protected void doStop()- Specified by:
doStop
in classAbstractLifecycleComponent
-
doClose
protected void doClose()- Specified by:
doClose
in classAbstractLifecycleComponent
-
executeDfsPhase
public void executeDfsPhase(ShardSearchRequest request, SearchShardTask task, ActionListener<SearchPhaseResult> listener) -
executeQueryPhase
public void executeQueryPhase(ShardSearchRequest request, SearchShardTask task, ActionListener<SearchPhaseResult> listener) -
executeQueryPhase
public void executeQueryPhase(InternalScrollSearchRequest request, SearchShardTask task, ActionListener<ScrollQuerySearchResult> listener) -
executeQueryPhase
public void executeQueryPhase(QuerySearchRequest request, SearchShardTask task, ActionListener<QuerySearchResult> listener) -
executeFetchPhase
public void executeFetchPhase(InternalScrollSearchRequest request, SearchShardTask task, ActionListener<ScrollQueryFetchSearchResult> listener) -
executeFetchPhase
public void executeFetchPhase(ShardFetchRequest request, SearchShardTask task, ActionListener<FetchSearchResult> listener) -
createSearchContext
public org.elasticsearch.search.DefaultSearchContext createSearchContext(ShardSearchRequest request, TimeValue timeout) throws java.io.IOException- Throws:
java.io.IOException
-
freeContext
-
freeAllScrollContexts
public void freeAllScrollContexts() -
getActiveContexts
public int getActiveContexts()Returns the number of active contexts in this SearchService -
getResponseCollectorService
-
buildAliasFilter
public AliasFilter buildAliasFilter(ClusterState state, java.lang.String index, java.util.Set<java.lang.String> resolvedExpressions) -
canMatch
public SearchService.CanMatchResponse canMatch(ShardSearchRequest request) throws java.io.IOExceptionThis method does a very quick rewrite of the query and returns true if the query can potentially match any documents. This method can have false positives while if it returnsfalse
the query won't match any documents on the current shard.- Throws:
java.io.IOException
-
canMatch
public void canMatch(ShardSearchRequest request, ActionListener<SearchService.CanMatchResponse> listener) -
canRewriteToMatchNone
Returns true iff the given search source builder can be early terminated by rewriting to a match none query. Or in other words if the execution of the search request can be early terminated without executing it. This is for instance not possible if a global aggregation is part of this request or if there is a suggest builder present. -
getRewriteContext
Returns a newQueryRewriteContext
with the givennow
provider -
getIndicesService
-
aggReduceContextBuilder
Returns a builder forInternalAggregation.ReduceContext
. This builder retains a reference to the providedSearchRequest
.
-