java.lang.Object
org.elasticsearch.transport.TransportMessage
org.elasticsearch.transport.TransportResponse
org.elasticsearch.search.SearchPhaseResult
org.elasticsearch.search.query.QuerySearchResult
- All Implemented Interfaces:
Writeable
,RefCounted
-
Nested Class Summary
Nested classes/interfaces inherited from class org.elasticsearch.transport.TransportResponse
TransportResponse.Empty
Nested classes/interfaces inherited from interface org.elasticsearch.common.io.stream.Writeable
Writeable.Reader<V>, Writeable.Writer<V>
-
Field Summary
Fields inherited from class org.elasticsearch.search.SearchPhaseResult
contextId
Fields inherited from interface org.elasticsearch.core.RefCounted
ALWAYS_REFERENCED
-
Constructor Summary
ConstructorsConstructorDescriptionQuerySearchResult
(StreamInput in, boolean delayedAggregations) Read the object, but using a delayed aggregations field when delayedAggregations=true.QuerySearchResult
(ShardSearchContextId contextId, SearchShardTarget shardTarget, ShardSearchRequest shardSearchRequest) -
Method Summary
Modifier and TypeMethodDescriptionvoid
addReleasable
(Releasable releasable) void
aggregations
(InternalAggregations aggregations) void
Returns and nulls out the profiled results for this search, or potentially null if result was empty.Returns and nulls out the top docs for this search results.boolean
decRef()
Note that the lifetime of an outboundTransportMessage
lasts at least until it has been fully sent over the network, and it may be closed on a network thread in a context in which there's a risk of stack overflows if on close it calls back into the network layer in a manner that might end up nesting too deeply.int
from()
from
(int from) getAggs()
Returns the aggregation as aDelayableWriteable
object.float
org.apache.lucene.search.TotalHits
boolean
hasAggs()
Returnstrue
if this query result has unconsumed aggregationsboolean
Returnstrue
iff the top docs have already been consumed.boolean
boolean
boolean
Specifies whether the specific search phase results are associated with an opened SearchContext on the shards that executed the request.boolean
Returnstrue
if this result has any suggest score docsvoid
incRef()
boolean
isNull()
Returns true if the result doesn't contain any useful information.int
nodeQueueSize
(int nodeQueueSize) static QuerySearchResult
Returns an instance that contains no response.void
profileResults
(SearchProfileQueryPhaseResult shardResults) Sets the finalized profiling results for this queryReturns the query result iff it's included in this response otherwisenull
void
void
Release the memory hold by theDelayableWriteable
aggregationsboolean
void
searchTimedOut
(boolean searchTimedOut) long
serviceTimeEWMA
(long serviceTimeEWMA) void
setRankShardResult
(RankShardResult rankShardResult) void
setSearchProfileDfsPhaseResult
(SearchProfileDfsPhaseResult searchProfileDfsPhaseResult) int
size()
Returns the maximum size of this results top docs.size
(int size) suggest()
void
void
terminatedEarly
(boolean terminatedEarly) topDocs()
void
topDocs
(TopDocsAndMaxScore topDocs, DocValueFormat[] sortValueFormats) boolean
void
writeTo
(StreamOutput out) Write this into the StreamOutput.void
writeToNoId
(StreamOutput out) Methods inherited from class org.elasticsearch.search.SearchPhaseResult
fetchResult, getContextId, getRescoreDocIds, getSearchShardTarget, getShardIndex, getShardSearchRequest, rankFeatureResult, setRescoreDocIds, setSearchShardTarget, setShardIndex, setShardSearchRequest
Methods inherited from class org.elasticsearch.transport.TransportMessage
remoteAddress, remoteAddress
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods inherited from interface org.elasticsearch.core.RefCounted
mustIncRef
-
Constructor Details
-
QuerySearchResult
public QuerySearchResult() -
QuerySearchResult
- Throws:
IOException
-
QuerySearchResult
Read the object, but using a delayed aggregations field when delayedAggregations=true. Using this, the caller must ensure that either `consumeAggs` or `releaseAggs` is called if `hasAggs() == true`.- Parameters:
delayedAggregations
- whether to use delayed aggregations or not- Throws:
IOException
-
QuerySearchResult
public QuerySearchResult(ShardSearchContextId contextId, SearchShardTarget shardTarget, ShardSearchRequest shardSearchRequest)
-
-
Method Details
-
nullInstance
Returns an instance that contains no response. -
isNull
public boolean isNull()Returns true if the result doesn't contain any useful information. It is used by the search action to avoid creating an empty response on shard request that rewrites to match_no_docs. TODO: Currently we need the concrete aggregators to build empty responses. This means that we cannot build an empty response in the coordinating node so we rely on this hack to ensure that at least one shard returns a valid empty response. We should move the ability to create empty responses to aggregation builders in order to allow building empty responses directly from the coordinating node. -
queryResult
Description copied from class:SearchPhaseResult
Returns the query result iff it's included in this response otherwisenull
- Overrides:
queryResult
in classSearchPhaseResult
-
searchTimedOut
public void searchTimedOut(boolean searchTimedOut) -
searchTimedOut
public boolean searchTimedOut() -
terminatedEarly
public void terminatedEarly(boolean terminatedEarly) -
terminatedEarly
-
topDocs
-
hasConsumedTopDocs
public boolean hasConsumedTopDocs()Returnstrue
iff the top docs have already been consumed. -
consumeTopDocs
Returns and nulls out the top docs for this search results. This allows to free up memory once the top docs are consumed.- Throws:
IllegalStateException
- if the top docs have already been consumed.
-
topDocs
-
setRankShardResult
-
getRankShardResult
-
sortValueFormats
-
hasAggs
public boolean hasAggs()Returnstrue
if this query result has unconsumed aggregations -
getAggs
Returns the aggregation as aDelayableWriteable
object. Callers are free to expand them whenever they wat but they should callreleaseAggs()
in order to free memory,- Throws:
IllegalStateException
- ifreleaseAggs()
has already being called.
-
releaseAggs
public void releaseAggs()Release the memory hold by theDelayableWriteable
aggregations- Throws:
IllegalStateException
- ifreleaseAggs()
has already being called.
-
addReleasable
-
aggregations
-
aggregations
-
setSearchProfileDfsPhaseResult
-
consumeProfileResult
Returns and nulls out the profiled results for this search, or potentially null if result was empty. This allows to free up memory once the profiled result is consumed.- Throws:
IllegalStateException
- if the profiled result has already been consumed.
-
hasProfileResults
public boolean hasProfileResults() -
consumeAll
public void consumeAll() -
profileResults
Sets the finalized profiling results for this query- Parameters:
shardResults
- The finalized profile
-
suggest
-
suggest
-
from
public int from() -
from
-
size
public int size()Returns the maximum size of this results top docs. -
size
-
serviceTimeEWMA
public long serviceTimeEWMA() -
serviceTimeEWMA
-
nodeQueueSize
public int nodeQueueSize() -
nodeQueueSize
-
hasSuggestHits
public boolean hasSuggestHits()Returnstrue
if this result has any suggest score docs -
hasSearchContext
public boolean hasSearchContext()Description copied from class:SearchPhaseResult
Specifies whether the specific search phase results are associated with an opened SearchContext on the shards that executed the request.- Overrides:
hasSearchContext
in classSearchPhaseResult
-
readFromWithId
- Throws:
IOException
-
writeTo
Description copied from interface:Writeable
Write this into the StreamOutput.- Specified by:
writeTo
in interfaceWriteable
- Overrides:
writeTo
in classSearchPhaseResult
- Throws:
IOException
-
writeToNoId
- Throws:
IOException
-
getTotalHits
-
getMaxScore
public float getMaxScore() -
incRef
public void incRef()- Specified by:
incRef
in interfaceRefCounted
- Overrides:
incRef
in classTransportMessage
-
tryIncRef
public boolean tryIncRef()- Specified by:
tryIncRef
in interfaceRefCounted
- Overrides:
tryIncRef
in classTransportMessage
-
decRef
public boolean decRef()Description copied from class:TransportMessage
Note that the lifetime of an outboundTransportMessage
lasts at least until it has been fully sent over the network, and it may be closed on a network thread in a context in which there's a risk of stack overflows if on close it calls back into the network layer in a manner that might end up nesting too deeply. When in doubt, dispatch any further work onto a separate thread.- Specified by:
decRef
in interfaceRefCounted
- Overrides:
decRef
in classTransportMessage
-
hasReferences
public boolean hasReferences()- Specified by:
hasReferences
in interfaceRefCounted
- Overrides:
hasReferences
in classTransportMessage
-