public abstract class SearchContext extends AbstractRefCounted implements Releasable
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.Modifier and Type | Class and Description |
---|---|
static class |
SearchContext.Lifetime
The life time of an object that is used during search execution.
|
Modifier and Type | Field and Description |
---|---|
static int |
DEFAULT_TERMINATE_AFTER |
Modifier | Constructor and Description |
---|---|
protected |
SearchContext() |
Modifier and Type | Method and Description |
---|---|
abstract void |
accessed(long accessTime) |
void |
addReleasable(Releasable releasable,
SearchContext.Lifetime lifetime)
Schedule the release of a resource.
|
abstract void |
addRescore(RescoreSearchContext rescore) |
abstract void |
addSearchExt(SearchExtBuilder searchExtBuilder) |
abstract SearchContextAggregations |
aggregations() |
abstract SearchContext |
aggregations(SearchContextAggregations aggregations) |
abstract org.apache.lucene.search.Query |
aliasFilter() |
protected void |
alreadyClosed() |
abstract BigArrays |
bigArrays() |
abstract BitsetFilterCache |
bitsetFilterCache() |
abstract org.apache.lucene.search.Query |
buildFilteredQuery(org.apache.lucene.search.Query query)
Automatically apply all required filters to the given query such as
alias filters, types filters, etc.
|
void |
clearReleasables(SearchContext.Lifetime lifetime) |
void |
close() |
protected void |
closeInternal() |
abstract CollapseContext |
collapse() |
abstract SearchContext |
collapse(CollapseContext collapse) |
abstract DfsSearchResult |
dfsResult() |
abstract int[] |
docIdsToLoad() |
abstract SearchContext |
docIdsToLoad(int[] docIdsToLoad,
int docsIdsToLoadFrom,
int docsIdsToLoadSize) |
abstract int |
docIdsToLoadFrom() |
abstract int |
docIdsToLoadSize() |
protected abstract void |
doClose() |
abstract DocValueFieldsContext |
docValueFieldsContext() |
abstract SearchContext |
docValueFieldsContext(DocValueFieldsContext docValueFieldsContext) |
abstract boolean |
explain() |
abstract void |
explain(boolean explain) |
abstract FetchPhase |
fetchPhase() |
abstract FetchSearchResult |
fetchResult() |
abstract FetchSourceContext |
fetchSourceContext() |
abstract SearchContext |
fetchSourceContext(FetchSourceContext fetchSourceContext) |
abstract IndexFieldDataService |
fieldData() |
abstract int |
from() |
abstract SearchContext |
from(int from) |
abstract ObjectMapper |
getObjectMapper(java.lang.String name) |
abstract long |
getOriginNanoTime() |
abstract Profilers |
getProfilers()
Return a handle over the profilers for the current search request, or
null if profiling is not enabled. |
abstract QueryShardContext |
getQueryShardContext() |
abstract SearchExtBuilder |
getSearchExt(java.lang.String name) |
abstract SearchTask |
getTask() |
abstract java.util.List<java.lang.String> |
groupStats() |
abstract void |
groupStats(java.util.List<java.lang.String> groupStats) |
abstract boolean |
hasFetchSourceContext() |
boolean |
hasOnlySuggest() |
abstract boolean |
hasScriptFields() |
abstract boolean |
hasStoredFields() |
abstract boolean |
hasStoredFieldsContext() |
abstract SearchContextHighlight |
highlight() |
abstract void |
highlight(SearchContextHighlight highlight) |
abstract long |
id() |
abstract IndexShard |
indexShard() |
InnerHitsContext |
innerHits() |
abstract boolean |
isCancelled() |
abstract long |
keepAlive() |
abstract void |
keepAlive(long keepAlive) |
abstract long |
lastAccessTime() |
SearchLookup |
lookup() |
abstract boolean |
lowLevelCancellation()
Indicates if the current index should perform frequent low level search cancellation check.
|
abstract MapperService |
mapperService() |
abstract java.lang.Float |
minimumScore() |
abstract SearchContext |
minimumScore(float minimumScore) |
abstract int |
numberOfShards() |
abstract ParsedQuery |
parsedPostFilter() |
abstract SearchContext |
parsedPostFilter(ParsedQuery postFilter) |
abstract ParsedQuery |
parsedQuery() |
abstract SearchContext |
parsedQuery(ParsedQuery query) |
abstract void |
preProcess(boolean rewrite)
Should be called before executing the main query and after all other parameters have been set.
|
abstract org.apache.lucene.search.Query |
query()
The query to execute, might be rewritten.
|
abstract float |
queryBoost() |
abstract java.util.Map<java.lang.Class<?>,org.apache.lucene.search.Collector> |
queryCollectors()
Return a view of the additional query collectors that should be run for this context.
|
abstract QuerySearchResult |
queryResult() |
abstract ShardSearchRequest |
request() |
abstract java.util.List<RescoreSearchContext> |
rescore() |
abstract ScriptFieldsContext |
scriptFields() |
abstract ScrollContext |
scrollContext() |
abstract SearchContext |
scrollContext(ScrollContext scroll) |
abstract org.apache.lucene.search.FieldDoc |
searchAfter() |
abstract SearchContext |
searchAfter(org.apache.lucene.search.FieldDoc searchAfter) |
abstract ContextIndexSearcher |
searcher() |
abstract SearchType |
searchType() |
abstract void |
setTask(SearchTask task) |
abstract SearchShardTarget |
shardTarget() |
abstract SimilarityService |
similarityService() |
abstract int |
size() |
abstract SearchContext |
size(int size) |
abstract MappedFieldType |
smartNameFieldType(java.lang.String name)
Looks up the given field, but does not restrict to fields in the types set on this context.
|
abstract SortAndFormats |
sort() |
abstract SearchContext |
sort(SortAndFormats sort) |
abstract java.lang.String |
source() |
abstract boolean |
sourceRequested()
A shortcut function to see whether there is a fetchSourceContext and it says the source is requested.
|
abstract StoredFieldsContext |
storedFieldsContext() |
abstract SearchContext |
storedFieldsContext(StoredFieldsContext storedFieldsContext) |
abstract boolean |
storedFieldsRequested()
A shortcut function to see whether there is a storedFieldsContext and it says the fields are requested.
|
abstract SuggestionSearchContext |
suggest() |
abstract void |
suggest(SuggestionSearchContext suggest) |
abstract int |
terminateAfter() |
abstract void |
terminateAfter(int terminateAfter) |
abstract org.apache.lucene.util.Counter |
timeEstimateCounter() |
abstract TimeValue |
timeout() |
abstract void |
timeout(TimeValue timeout) |
java.lang.String |
toString() |
abstract boolean |
trackScores() |
abstract SearchContext |
trackScores(boolean trackScores) |
abstract boolean |
version() |
abstract void |
version(boolean version) |
public static final int DEFAULT_TERMINATE_AFTER
public abstract void setTask(SearchTask task)
public abstract SearchTask getTask()
public abstract boolean isCancelled()
public final void close()
close
in interface java.io.Closeable
close
in interface java.lang.AutoCloseable
close
in interface Releasable
protected final void closeInternal()
closeInternal
in class AbstractRefCounted
protected void alreadyClosed()
alreadyClosed
in class AbstractRefCounted
protected abstract void doClose()
public abstract void preProcess(boolean rewrite)
rewrite
- if the set query should be rewritten against the searcher returned from searcher()
public abstract org.apache.lucene.search.Query buildFilteredQuery(org.apache.lucene.search.Query query)
public abstract long id()
public abstract java.lang.String source()
public abstract ShardSearchRequest request()
public abstract SearchType searchType()
public abstract SearchShardTarget shardTarget()
public abstract int numberOfShards()
public abstract float queryBoost()
public abstract long getOriginNanoTime()
public abstract ScrollContext scrollContext()
public abstract SearchContext scrollContext(ScrollContext scroll)
public abstract SearchContextAggregations aggregations()
public abstract SearchContext aggregations(SearchContextAggregations aggregations)
public abstract void addSearchExt(SearchExtBuilder searchExtBuilder)
public abstract SearchExtBuilder getSearchExt(java.lang.String name)
public abstract SearchContextHighlight highlight()
public abstract void highlight(SearchContextHighlight highlight)
public InnerHitsContext innerHits()
public abstract SuggestionSearchContext suggest()
public abstract void suggest(SuggestionSearchContext suggest)
public abstract java.util.List<RescoreSearchContext> rescore()
public abstract void addRescore(RescoreSearchContext rescore)
public abstract boolean hasScriptFields()
public abstract ScriptFieldsContext scriptFields()
public abstract boolean sourceRequested()
public abstract boolean hasFetchSourceContext()
public abstract FetchSourceContext fetchSourceContext()
public abstract SearchContext fetchSourceContext(FetchSourceContext fetchSourceContext)
public abstract DocValueFieldsContext docValueFieldsContext()
public abstract SearchContext docValueFieldsContext(DocValueFieldsContext docValueFieldsContext)
public abstract ContextIndexSearcher searcher()
public abstract IndexShard indexShard()
public abstract MapperService mapperService()
public abstract SimilarityService similarityService()
public abstract BigArrays bigArrays()
public abstract BitsetFilterCache bitsetFilterCache()
public abstract IndexFieldDataService fieldData()
public abstract TimeValue timeout()
public abstract void timeout(TimeValue timeout)
public abstract int terminateAfter()
public abstract void terminateAfter(int terminateAfter)
public abstract boolean lowLevelCancellation()
public abstract SearchContext minimumScore(float minimumScore)
public abstract java.lang.Float minimumScore()
public abstract SearchContext sort(SortAndFormats sort)
public abstract SortAndFormats sort()
public abstract SearchContext trackScores(boolean trackScores)
public abstract boolean trackScores()
public abstract SearchContext searchAfter(org.apache.lucene.search.FieldDoc searchAfter)
public abstract org.apache.lucene.search.FieldDoc searchAfter()
public abstract SearchContext collapse(CollapseContext collapse)
public abstract CollapseContext collapse()
public abstract SearchContext parsedPostFilter(ParsedQuery postFilter)
public abstract ParsedQuery parsedPostFilter()
public abstract org.apache.lucene.search.Query aliasFilter()
public abstract SearchContext parsedQuery(ParsedQuery query)
public abstract ParsedQuery parsedQuery()
public abstract org.apache.lucene.search.Query query()
public abstract int from()
public abstract SearchContext from(int from)
public abstract int size()
public abstract SearchContext size(int size)
public abstract boolean hasStoredFields()
public abstract boolean hasStoredFieldsContext()
public abstract boolean storedFieldsRequested()
public abstract StoredFieldsContext storedFieldsContext()
public abstract SearchContext storedFieldsContext(StoredFieldsContext storedFieldsContext)
public abstract boolean explain()
public abstract void explain(boolean explain)
@Nullable public abstract java.util.List<java.lang.String> groupStats()
public abstract void groupStats(java.util.List<java.lang.String> groupStats)
public abstract boolean version()
public abstract void version(boolean version)
public abstract int[] docIdsToLoad()
public abstract int docIdsToLoadFrom()
public abstract int docIdsToLoadSize()
public abstract SearchContext docIdsToLoad(int[] docIdsToLoad, int docsIdsToLoadFrom, int docsIdsToLoadSize)
public abstract void accessed(long accessTime)
public abstract long lastAccessTime()
public abstract long keepAlive()
public abstract void keepAlive(long keepAlive)
public SearchLookup lookup()
public abstract DfsSearchResult dfsResult()
public abstract QuerySearchResult queryResult()
public abstract FetchPhase fetchPhase()
public abstract FetchSearchResult fetchResult()
public abstract Profilers getProfilers()
null
if profiling is not enabled.public void addReleasable(Releasable releasable, SearchContext.Lifetime lifetime)
Releasable.close()
will be called on this object
is function of the provided SearchContext.Lifetime
.public void clearReleasables(SearchContext.Lifetime lifetime)
public final boolean hasOnlySuggest()
public abstract MappedFieldType smartNameFieldType(java.lang.String name)
public abstract ObjectMapper getObjectMapper(java.lang.String name)
public abstract org.apache.lucene.util.Counter timeEstimateCounter()
public abstract java.util.Map<java.lang.Class<?>,org.apache.lucene.search.Collector> queryCollectors()
public abstract QueryShardContext getQueryShardContext()
public java.lang.String toString()
toString
in class java.lang.Object