public abstract class SearchContext extends DelegatingHasContextAndHeaders implements Releasable, RefCounted
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 |
protected ParseFieldMatcher |
parseFieldMatcher |
Modifier | Constructor and Description |
---|---|
protected |
SearchContext(ParseFieldMatcher parseFieldMatcher,
HasContextAndHeaders contextHeaders) |
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 SearchContextAggregations |
aggregations() |
abstract SearchContext |
aggregations(SearchContextAggregations aggregations) |
abstract org.apache.lucene.search.Query |
aliasFilter() |
protected void |
alreadyClosed() |
abstract AnalysisService |
analysisService() |
abstract BigArrays |
bigArrays() |
abstract BitsetFilterCache |
bitsetFilterCache() |
void |
clearReleasables(SearchContext.Lifetime lifetime) |
void |
close() |
static SearchContext |
current() |
void |
decRef()
Decreases the refCount of this instance.
|
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 void |
emptyFieldNames() |
abstract boolean |
explain() |
abstract void |
explain(boolean explain) |
abstract FetchSearchResult |
fetchResult() |
abstract FetchSourceContext |
fetchSourceContext() |
abstract SearchContext |
fetchSourceContext(FetchSourceContext fetchSourceContext) |
abstract IndexFieldDataService |
fieldData() |
abstract List<String> |
fieldNames() |
abstract int |
from() |
abstract SearchContext |
from(int from) |
abstract <SubPhaseContext extends FetchSubPhaseContext> |
getFetchSubPhaseContext(FetchSubPhase.ContextFactory<SubPhaseContext> contextFactory) |
abstract ObjectMapper |
getObjectMapper(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 List<String> |
groupStats() |
abstract void |
groupStats(List<String> groupStats) |
abstract boolean |
hasFetchSourceContext() |
abstract boolean |
hasFieldNames() |
abstract boolean |
hasScriptFields() |
abstract boolean |
hasTypes() |
abstract SearchContextHighlight |
highlight() |
abstract void |
highlight(SearchContextHighlight highlight) |
abstract long |
id() |
void |
incRef()
Increments the refCount of this instance.
|
abstract IndexShard |
indexShard() |
InnerHitsContext |
innerHits() |
abstract long |
keepAlive() |
abstract void |
keepAlive(long keepAlive) |
abstract long |
lastAccessTime() |
abstract SearchLookup |
lookup() |
abstract MapperService |
mapperService() |
abstract Float |
minimumScore() |
abstract SearchContext |
minimumScore(float minimumScore) |
long |
nowInMillis() |
protected abstract long |
nowInMillisImpl() |
boolean |
nowInMillisUsed() |
abstract int |
numberOfShards() |
abstract PageCacheRecycler |
pageCacheRecycler() |
abstract ParsedQuery |
parsedPostFilter() |
abstract SearchContext |
parsedPostFilter(ParsedQuery postFilter) |
abstract ParsedQuery |
parsedQuery() |
abstract SearchContext |
parsedQuery(ParsedQuery query) |
ParseFieldMatcher |
parseFieldMatcher() |
abstract void |
preProcess()
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 SearchContext |
queryBoost(float queryBoost) |
abstract Map<Class<?>,org.apache.lucene.search.Collector> |
queryCollectors()
Return a view of the additional query collectors that should be run for this context.
|
abstract IndexQueryParserService |
queryParserService() |
abstract QuerySearchResult |
queryResult() |
int |
refCount()
Returns the current reference count.
|
static void |
removeCurrent() |
abstract ShardSearchRequest |
request() |
abstract List<RescoreSearchContext> |
rescore() |
abstract ScanContext |
scanContext() |
abstract ScriptFieldsContext |
scriptFields() |
abstract ScriptService |
scriptService() |
abstract ScrollContext |
scrollContext() |
abstract SearchContext |
scrollContext(ScrollContext scroll) |
abstract ContextIndexSearcher |
searcher() |
abstract org.apache.lucene.search.Query |
searchFilter(String[] types) |
abstract SearchType |
searchType() |
abstract SearchContext |
searchType(SearchType searchType) |
static void |
setCurrent(SearchContext value) |
abstract SearchShardTarget |
shardTarget() |
abstract SimilarityService |
similarityService() |
abstract int |
size() |
abstract SearchContext |
size(int size) |
abstract MappedFieldType |
smartNameFieldType(String name) |
abstract MappedFieldType |
smartNameFieldTypeFromAnyType(String name)
Looks up the given field, but does not restrict to fields in the types set on this context.
|
abstract org.apache.lucene.search.Sort |
sort() |
abstract SearchContext |
sort(org.apache.lucene.search.Sort sort) |
abstract String |
source() |
abstract boolean |
sourceRequested()
A shortcut function to see whether there is a fetchSourceContext and it says the source is 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 long |
timeoutInMillis() |
abstract void |
timeoutInMillis(long timeoutInMillis) |
abstract boolean |
trackScores() |
abstract SearchContext |
trackScores(boolean trackScores) |
boolean |
tryIncRef()
Tries to increment the refCount of this instance.
|
abstract String[] |
types() |
abstract boolean |
version() |
abstract void |
version(boolean version) |
contextSize, copyContextAndHeadersFrom, copyContextFrom, copyHeadersFrom, getContext, getFromContext, getFromContext, getHeader, getHeaders, hasHeader, hasInContext, isContextEmpty, putAllInContext, putHeader, putInContext
public static final int DEFAULT_TERMINATE_AFTER
protected final ParseFieldMatcher parseFieldMatcher
protected SearchContext(ParseFieldMatcher parseFieldMatcher, HasContextAndHeaders contextHeaders)
public static void setCurrent(SearchContext value)
public static void removeCurrent()
public static SearchContext current()
public ParseFieldMatcher parseFieldMatcher()
public final void close()
close
in interface AutoCloseable
close
in interface Releasable
protected abstract void doClose()
public abstract void preProcess()
public abstract org.apache.lucene.search.Query searchFilter(String[] types)
public abstract long id()
public abstract String source()
public abstract ShardSearchRequest request()
public abstract SearchType searchType()
public abstract SearchContext searchType(SearchType searchType)
public abstract SearchShardTarget shardTarget()
public abstract int numberOfShards()
public abstract boolean hasTypes()
public abstract String[] types()
public abstract float queryBoost()
public abstract SearchContext queryBoost(float queryBoost)
public abstract long getOriginNanoTime()
public final long nowInMillis()
public final boolean nowInMillisUsed()
protected abstract long nowInMillisImpl()
public abstract ScrollContext scrollContext()
public abstract SearchContext scrollContext(ScrollContext scroll)
public abstract SearchContextAggregations aggregations()
public abstract SearchContext aggregations(SearchContextAggregations aggregations)
public abstract <SubPhaseContext extends FetchSubPhaseContext> SubPhaseContext getFetchSubPhaseContext(FetchSubPhase.ContextFactory<SubPhaseContext> contextFactory)
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 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 ContextIndexSearcher searcher()
public abstract IndexShard indexShard()
public abstract MapperService mapperService()
public abstract AnalysisService analysisService()
public abstract IndexQueryParserService queryParserService()
public abstract SimilarityService similarityService()
public abstract ScriptService scriptService()
public abstract PageCacheRecycler pageCacheRecycler()
public abstract BigArrays bigArrays()
public abstract BitsetFilterCache bitsetFilterCache()
public abstract IndexFieldDataService fieldData()
public abstract long timeoutInMillis()
public abstract void timeoutInMillis(long timeoutInMillis)
public abstract int terminateAfter()
public abstract void terminateAfter(int terminateAfter)
public abstract SearchContext minimumScore(float minimumScore)
public abstract Float minimumScore()
public abstract SearchContext sort(org.apache.lucene.search.Sort sort)
public abstract org.apache.lucene.search.Sort sort()
public abstract SearchContext trackScores(boolean trackScores)
public abstract boolean trackScores()
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 hasFieldNames()
public abstract void emptyFieldNames()
public abstract boolean explain()
public abstract void explain(boolean explain)
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 abstract SearchLookup lookup()
public abstract DfsSearchResult dfsResult()
public abstract QuerySearchResult queryResult()
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 abstract ScanContext scanContext()
public abstract MappedFieldType smartNameFieldType(String name)
public abstract MappedFieldType smartNameFieldTypeFromAnyType(String name)
public abstract ObjectMapper getObjectMapper(String name)
public abstract org.apache.lucene.util.Counter timeEstimateCounter()
public abstract Map<Class<?>,org.apache.lucene.search.Collector> queryCollectors()
public final void incRef()
RefCounted
incRef
in interface RefCounted
RefCounted.decRef()
,
RefCounted.tryIncRef()
public final boolean tryIncRef()
RefCounted
tryIncRef
in interface RefCounted
RefCounted.decRef()
,
RefCounted.incRef()
public final void decRef()
RefCounted
decRef
in interface RefCounted
RefCounted.incRef()
protected void alreadyClosed()
public int refCount()
Copyright © 2009–2016. All rights reserved.