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>
DEFAULT_ALLOW_PARTIAL_SEARCH_RESULTS
static Setting<TimeValue>
DEFAULT_KEEPALIVE_SETTING
static Setting<TimeValue>
DEFAULT_SEARCH_TIMEOUT_SETTING
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
-
Fields inherited from class org.elasticsearch.common.component.AbstractLifecycleComponent
lifecycle
-
-
Constructor Summary
Constructors Constructor Description SearchService(ClusterService clusterService, IndicesService indicesService, ThreadPool threadPool, ScriptService scriptService, BigArrays bigArrays, FetchPhase fetchPhase, ResponseCollectorService responseCollectorService)
-
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, shardRoutingChanged
-
-
-
-
Field Detail
-
LOW_LEVEL_CANCELLATION_SETTING
public static final Setting<java.lang.Boolean> 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. However, since it will produce more cancellation checks it might slow the search performance down.
-
NO_TIMEOUT
public static final TimeValue NO_TIMEOUT
-
DEFAULT_SEARCH_TIMEOUT_SETTING
public static final Setting<TimeValue> DEFAULT_SEARCH_TIMEOUT_SETTING
-
DEFAULT_ALLOW_PARTIAL_SEARCH_RESULTS
public static final Setting<java.lang.Boolean> DEFAULT_ALLOW_PARTIAL_SEARCH_RESULTS
-
MAX_OPEN_SCROLL_CONTEXT
public static final Setting<java.lang.Integer> MAX_OPEN_SCROLL_CONTEXT
-
-
Constructor Detail
-
SearchService
public SearchService(ClusterService clusterService, IndicesService indicesService, ThreadPool threadPool, ScriptService scriptService, BigArrays bigArrays, FetchPhase fetchPhase, ResponseCollectorService responseCollectorService)
-
-
Method Detail
-
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
protected void putContext(SearchContext context)
-
removeContext
protected SearchContext removeContext(long id)
-
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, SearchTask task, ActionListener<SearchPhaseResult> listener)
-
executeQueryPhase
public void executeQueryPhase(ShardSearchRequest request, SearchTask task, ActionListener<SearchPhaseResult> listener)
-
executeQueryPhase
public void executeQueryPhase(InternalScrollSearchRequest request, SearchTask task, ActionListener<ScrollQuerySearchResult> listener)
-
executeQueryPhase
public void executeQueryPhase(QuerySearchRequest request, SearchTask task, ActionListener<QuerySearchResult> listener)
-
executeFetchPhase
public void executeFetchPhase(InternalScrollSearchRequest request, SearchTask task, ActionListener<ScrollQueryFetchSearchResult> listener)
-
executeFetchPhase
public void executeFetchPhase(ShardFetchRequest request, SearchTask task, ActionListener<FetchSearchResult> listener)
-
createSearchContext
public org.elasticsearch.search.DefaultSearchContext createSearchContext(ShardSearchRequest request, TimeValue timeout) throws java.io.IOException
- Throws:
java.io.IOException
-
freeContext
public boolean freeContext(long id)
-
freeAllScrollContexts
public void freeAllScrollContexts()
-
getActiveContexts
public int getActiveContexts()
Returns the number of active contexts in this SearchService
-
getResponseCollectorService
public ResponseCollectorService getResponseCollectorService()
-
getIndicesService
public IndicesService getIndicesService()
-
buildAliasFilter
public AliasFilter buildAliasFilter(ClusterState state, java.lang.String index, java.util.Set<java.lang.String> resolvedExpressions)
-
canMatch
public boolean canMatch(ShardSearchRequest request) throws java.io.IOException
This 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
public static boolean canRewriteToMatchNone(SearchSourceBuilder source)
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
public QueryRewriteContext getRewriteContext(java.util.function.LongSupplier nowInMillis)
Returns a newQueryRewriteContext
with the givennow
provider
-
createReduceContext
public InternalAggregation.ReduceContext createReduceContext(boolean finalReduce)
-
-