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 classSearchService.CanMatchResponse -
Field Summary
Fields Modifier and Type Field Description static Setting<java.lang.Boolean>ALLOW_EXPENSIVE_QUERIESstatic Setting<java.lang.Boolean>DEFAULT_ALLOW_PARTIAL_SEARCH_RESULTSstatic intDEFAULT_FROMstatic Setting<org.elasticsearch.common.unit.TimeValue>DEFAULT_KEEPALIVE_SETTINGstatic Setting<org.elasticsearch.common.unit.TimeValue>DEFAULT_SEARCH_TIMEOUT_SETTINGstatic intDEFAULT_SIZEstatic Setting<org.elasticsearch.common.unit.TimeValue>KEEPALIVE_INTERVAL_SETTINGstatic Setting<java.lang.Boolean>LOW_LEVEL_CANCELLATION_SETTINGEnables low-level, frequent search cancellation checks.static Setting<org.elasticsearch.common.unit.TimeValue>MAX_KEEPALIVE_SETTINGstatic Setting<java.lang.Integer>MAX_OPEN_SCROLL_CONTEXTstatic org.elasticsearch.common.unit.TimeValueNO_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, stopMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.elasticsearch.index.shard.IndexEventListener
afterIndexCreated, afterIndexShardClosed, afterIndexShardCreated, afterIndexShardDeleted, afterIndexShardStarted, beforeIndexAddedToCluster, beforeIndexCreated, beforeIndexRemoved, beforeIndexShardClosed, beforeIndexShardCreated, beforeIndexShardDeleted, beforeIndexShardRecovery, 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
public static final org.elasticsearch.common.unit.TimeValue 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:IndexEventListenerCalled after the index has been removed.- Specified by:
afterIndexRemovedin interfaceIndexEventListener- Parameters:
index- The indexreason- the reason for index removal
-
putContext
-
removeContext
-
doStart
protected void doStart()- Specified by:
doStartin classAbstractLifecycleComponent
-
doStop
protected void doStop()- Specified by:
doStopin classAbstractLifecycleComponent
-
doClose
protected void doClose()- Specified by:
doClosein 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, org.elasticsearch.common.unit.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 returnsfalsethe 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 newQueryRewriteContextwith the givennowprovider -
getIndicesService
-
aggReduceContextBuilder
Returns a builder forInternalAggregation.ReduceContext. This builder retains a reference to the providedSearchRequest.
-