java.lang.Object
org.elasticsearch.search.internal.SearchContext
org.elasticsearch.search.rank.RankSearchContext
- All Implemented Interfaces:
Closeable
,AutoCloseable
,Releasable
Manages the appropriate values when executing multiple queries
on behalf of ranking for a single ranking query.
-
Field Summary
Fields inherited from class org.elasticsearch.search.internal.SearchContext
DEFAULT_TERMINATE_AFTER, DEFAULT_TRACK_TOTAL_HITS_UP_TO, releasables, TRACK_TOTAL_HITS_ACCURATE, TRACK_TOTAL_HITS_DISABLED
-
Constructor Summary
ConstructorsConstructorDescriptionRankSearchContext
(SearchContext parent, org.apache.lucene.search.Query rankQuery, int windowSize) -
Method Summary
Modifier and TypeMethodDescriptionvoid
Indicates that the caller will be using, and thus owning, aDfsSearchResult
object.void
Indicates that the caller will be using, and thus owning, aFetchSearchResult
object.void
Indicates that the caller will be using, and thus owning, aQuerySearchResult
object.void
addRescore
(RescoreContext rescore) void
addSearchExt
(SearchExtBuilder searchExtBuilder) Aggregations are run as a separate query.aggregations
(SearchContextAggregations aggregations) 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.collapse()
Collapse is not supported by ranking.collapse
(CollapseContext collapse) docValuesContext
(FetchDocValuesContext docValuesContext) boolean
explain()
void
explain
(boolean explain) The context related to retrieving fields.fetchFieldsContext
(FetchFieldsContext fetchFieldsContext) Sets the context related to retrieving fields.fetchSourceContext
(FetchSourceContext fetchSourceContext) int
from()
from
(int from) float
Profiling is not supported by ranking.long
Returns time in milliseconds that can be used for relative time calculations.getSearchExt
(String name) getTask()
org.apache.lucene.search.TotalHits
void
groupStats
(List<String> groupStats) boolean
boolean
void
highlight
(SearchHighlightContext highlight) id()
boolean
boolean
Indicates if the current index should perform frequent low level search cancellation check.minimumScore
(float minimumScore) Build something to load source_source
.int
parsedPostFilter
(ParsedQuery postFilter) parsedQuery
(ParsedQuery query) void
Should be called before executing the main query and after all other parameters have been set.org.apache.lucene.search.Query
query()
Use a single rank query.Use a separate query search result.void
rankShardContext
(RankShardContext rankShardContext) request()
rescore()
Rescore is not supported by ranking.Ranking is not allowed with scroll.org.apache.lucene.search.FieldDoc
searchAfter
(org.apache.lucene.search.FieldDoc searchAfter) searcher()
boolean
indicates whether the sequence number and primary term of the last modification to each hit should be returnedvoid
seqNoAndPrimaryTerm
(boolean seqNoAndPrimaryTerm) controls whether the sequence number and primary term of the last modification to each hit should be returnedvoid
setTask
(SearchShardTask task) int
size()
size
(int size) sort()
Sort is not allowed with ranking.sort
(SortAndFormats sort) source()
boolean
A shortcut function to see whether there is a fetchSourceContext and it says the source is requested.storedFieldsContext
(StoredFieldsContext storedFieldsContext) suggest()
void
suggest
(SuggestionSearchContext suggest) int
void
terminateAfter
(int terminateAfter) timeout()
void
boolean
trackScores
(boolean trackScores) int
Total hits are tracked as part of a separate query.trackTotalHitsUpTo
(int trackTotalHits) boolean
version()
void
version
(boolean version) Methods inherited from class org.elasticsearch.search.internal.SearchContext
addReleasable, assignRescoreDocIds, close, hasOnlySuggest, rescoreDocIds, rewrittenQuery, toString
-
Constructor Details
-
RankSearchContext
public RankSearchContext(SearchContext parent, org.apache.lucene.search.Query rankQuery, int windowSize)
-
-
Method Details
-
request
- Specified by:
request
in classSearchContext
-
shardTarget
- Specified by:
shardTarget
in classSearchContext
-
scrollContext
Ranking is not allowed with scroll.- Specified by:
scrollContext
in classSearchContext
-
aggregations
Aggregations are run as a separate query.- Specified by:
aggregations
in classSearchContext
-
rescore
Rescore is not supported by ranking.- Specified by:
rescore
in classSearchContext
- Returns:
- list of all rescore contexts. empty if there aren't any.
-
searcher
- Specified by:
searcher
in classSearchContext
-
indexShard
- Specified by:
indexShard
in classSearchContext
-
timeout
- Specified by:
timeout
in classSearchContext
-
terminateAfter
public int terminateAfter()- Specified by:
terminateAfter
in classSearchContext
-
minimumScore
- Specified by:
minimumScore
in classSearchContext
-
sort
Sort is not allowed with ranking.- Specified by:
sort
in classSearchContext
-
trackScores
public boolean trackScores()- Specified by:
trackScores
in classSearchContext
-
trackTotalHitsUpTo
public int trackTotalHitsUpTo()Total hits are tracked as part of a separate query.- Specified by:
trackTotalHitsUpTo
in classSearchContext
-
searchAfter
public org.apache.lucene.search.FieldDoc searchAfter()- Specified by:
searchAfter
in classSearchContext
-
collapse
Collapse is not supported by ranking.- Specified by:
collapse
in classSearchContext
-
parsedPostFilter
- Specified by:
parsedPostFilter
in classSearchContext
-
query
public org.apache.lucene.search.Query query()Use a single rank query.- Specified by:
query
in classSearchContext
-
from
public int from()- Specified by:
from
in classSearchContext
-
size
public int size()- Specified by:
size
in classSearchContext
-
queryResult
Use a separate query search result.- Specified by:
queryResult
in classSearchContext
-
getProfilers
Profiling is not supported by ranking.- Specified by:
getProfilers
in classSearchContext
-
getRelativeTimeInMillis
public long getRelativeTimeInMillis()Description copied from class:SearchContext
Returns time in milliseconds that can be used for relative time calculations. WARN: This is not the epoch time.- Specified by:
getRelativeTimeInMillis
in classSearchContext
-
setTask
- Specified by:
setTask
in classSearchContext
-
getTask
- Specified by:
getTask
in classSearchContext
-
isCancelled
public boolean isCancelled()- Specified by:
isCancelled
in classSearchContext
-
preProcess
public void preProcess()Description copied from class:SearchContext
Should be called before executing the main query and after all other parameters have been set.- Specified by:
preProcess
in classSearchContext
-
buildFilteredQuery
public org.apache.lucene.search.Query buildFilteredQuery(org.apache.lucene.search.Query query) Description copied from class:SearchContext
Automatically apply all required filters to the given query such as alias filters, types filters, etc.- Specified by:
buildFilteredQuery
in classSearchContext
-
id
- Specified by:
id
in classSearchContext
-
source
- Specified by:
source
in classSearchContext
-
searchType
- Specified by:
searchType
in classSearchContext
-
numberOfShards
public int numberOfShards()- Specified by:
numberOfShards
in classSearchContext
-
aggregations
- Specified by:
aggregations
in classSearchContext
-
addSearchExt
- Specified by:
addSearchExt
in classSearchContext
-
getSearchExt
- Specified by:
getSearchExt
in classSearchContext
-
highlight
- Specified by:
highlight
in classSearchContext
-
highlight
- Specified by:
highlight
in classSearchContext
-
innerHits
- Overrides:
innerHits
in classSearchContext
-
suggest
- Specified by:
suggest
in classSearchContext
-
suggest
- Specified by:
suggest
in classSearchContext
-
rankShardContext
- Specified by:
rankShardContext
in classSearchContext
-
rankShardContext
- Specified by:
rankShardContext
in classSearchContext
-
addRescore
- Specified by:
addRescore
in classSearchContext
-
hasScriptFields
public boolean hasScriptFields()- Specified by:
hasScriptFields
in classSearchContext
-
scriptFields
- Specified by:
scriptFields
in classSearchContext
-
sourceRequested
public boolean sourceRequested()Description copied from class:SearchContext
A shortcut function to see whether there is a fetchSourceContext and it says the source is requested.- Specified by:
sourceRequested
in classSearchContext
-
fetchSourceContext
- Specified by:
fetchSourceContext
in classSearchContext
-
fetchSourceContext
- Specified by:
fetchSourceContext
in classSearchContext
-
docValuesContext
- Specified by:
docValuesContext
in classSearchContext
-
docValuesContext
- Specified by:
docValuesContext
in classSearchContext
-
fetchFieldsContext
Description copied from class:SearchContext
The context related to retrieving fields.- Specified by:
fetchFieldsContext
in classSearchContext
-
fetchFieldsContext
Description copied from class:SearchContext
Sets the context related to retrieving fields.- Specified by:
fetchFieldsContext
in classSearchContext
-
bitsetFilterCache
- Specified by:
bitsetFilterCache
in classSearchContext
-
timeout
- Specified by:
timeout
in classSearchContext
-
terminateAfter
public void terminateAfter(int terminateAfter) - Specified by:
terminateAfter
in classSearchContext
-
lowLevelCancellation
public boolean lowLevelCancellation()Description copied from class:SearchContext
Indicates if the current index should perform frequent low level search cancellation check. 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.- Specified by:
lowLevelCancellation
in classSearchContext
-
minimumScore
- Specified by:
minimumScore
in classSearchContext
-
sort
- Specified by:
sort
in classSearchContext
-
trackScores
- Specified by:
trackScores
in classSearchContext
-
trackTotalHitsUpTo
- Specified by:
trackTotalHitsUpTo
in classSearchContext
-
searchAfter
- Specified by:
searchAfter
in classSearchContext
-
collapse
- Specified by:
collapse
in classSearchContext
-
parsedPostFilter
- Specified by:
parsedPostFilter
in classSearchContext
-
parsedQuery
- Specified by:
parsedQuery
in classSearchContext
-
parsedQuery
- Specified by:
parsedQuery
in classSearchContext
-
from
- Specified by:
from
in classSearchContext
-
size
- Specified by:
size
in classSearchContext
-
hasStoredFields
public boolean hasStoredFields()- Specified by:
hasStoredFields
in classSearchContext
-
storedFieldsContext
- Specified by:
storedFieldsContext
in classSearchContext
-
storedFieldsContext
- Specified by:
storedFieldsContext
in classSearchContext
-
explain
public boolean explain()- Specified by:
explain
in classSearchContext
-
explain
public void explain(boolean explain) - Specified by:
explain
in classSearchContext
-
groupStats
- Specified by:
groupStats
in classSearchContext
-
groupStats
- Specified by:
groupStats
in classSearchContext
-
version
public boolean version()- Specified by:
version
in classSearchContext
-
version
public void version(boolean version) - Specified by:
version
in classSearchContext
-
seqNoAndPrimaryTerm
public boolean seqNoAndPrimaryTerm()Description copied from class:SearchContext
indicates whether the sequence number and primary term of the last modification to each hit should be returned- Specified by:
seqNoAndPrimaryTerm
in classSearchContext
-
seqNoAndPrimaryTerm
public void seqNoAndPrimaryTerm(boolean seqNoAndPrimaryTerm) Description copied from class:SearchContext
controls whether the sequence number and primary term of the last modification to each hit should be returned- Specified by:
seqNoAndPrimaryTerm
in classSearchContext
-
dfsResult
- Specified by:
dfsResult
in classSearchContext
-
addDfsResult
public void addDfsResult()Description copied from class:SearchContext
Indicates that the caller will be using, and thus owning, aDfsSearchResult
object. It is the caller's responsibility to correctly cleanup this result object.- Specified by:
addDfsResult
in classSearchContext
-
addQueryResult
public void addQueryResult()Description copied from class:SearchContext
Indicates that the caller will be using, and thus owning, aQuerySearchResult
object. It is the caller's responsibility to correctly cleanup this result object.- Specified by:
addQueryResult
in classSearchContext
-
getTotalHits
public org.apache.lucene.search.TotalHits getTotalHits()- Specified by:
getTotalHits
in classSearchContext
-
getMaxScore
public float getMaxScore()- Specified by:
getMaxScore
in classSearchContext
-
fetchPhase
- Specified by:
fetchPhase
in classSearchContext
-
fetchResult
- Specified by:
fetchResult
in classSearchContext
-
addFetchResult
public void addFetchResult()Description copied from class:SearchContext
Indicates that the caller will be using, and thus owning, aFetchSearchResult
object. It is the caller's responsibility to correctly cleanup this result object.- Specified by:
addFetchResult
in classSearchContext
-
getSearchExecutionContext
- Specified by:
getSearchExecutionContext
in classSearchContext
-
readerContext
- Specified by:
readerContext
in classSearchContext
-
newSourceLoader
Description copied from class:SearchContext
Build something to load source_source
.- Specified by:
newSourceLoader
in classSearchContext
-
newIdLoader
- Specified by:
newIdLoader
in classSearchContext
-