Package org.elasticsearch.search.query
Class QuerySearchResult
java.lang.Object
org.elasticsearch.transport.TransportMessage
org.elasticsearch.transport.TransportResponse
org.elasticsearch.search.SearchPhaseResult
org.elasticsearch.search.query.QuerySearchResult
- All Implemented Interfaces:
Writeable
public final class QuerySearchResult extends SearchPhaseResult
-
Nested Class Summary
Nested classes/interfaces inherited from class org.elasticsearch.transport.TransportResponse
TransportResponse.EmptyNested classes/interfaces inherited from interface org.elasticsearch.common.io.stream.Writeable
Writeable.Reader<V>, Writeable.Writer<V> -
Field Summary
-
Constructor Summary
Constructors Constructor Description QuerySearchResult()QuerySearchResult(StreamInput in)QuerySearchResult(SearchContextId id, SearchShardTarget shardTarget) -
Method Summary
Modifier and Type Method Description DelayableWriteable<InternalAggregations>aggregations()voidaggregations(InternalAggregations aggregations)DelayableWriteable<InternalAggregations>consumeAggs()Returns and nulls out the aggregation for this search results.ProfileShardResultconsumeProfileResult()Returns and nulls out the profiled results for this search, or potentially null if result was empty.TopDocsAndMaxScoreconsumeTopDocs()Returns and nulls out the top docs for this search results.intfrom()QuerySearchResultfrom(int from)floatgetMaxScore()org.apache.lucene.search.TotalHitsgetTotalHits()booleanhasAggs()Returnstrueif this query result has unconsumed aggregationsbooleanhasConsumedTopDocs()Returnstrueiff the top docs have already been consumed.booleanhasProfileResults()booleanhasSearchContext()booleanhasSuggestHits()Returnstrueif this result has any suggest score docsbooleanisNull()Returns true if the result doesn't contain any useful information.intnodeQueueSize()QuerySearchResultnodeQueueSize(int nodeQueueSize)static QuerySearchResultnullInstance()Returns an instance that contains no response.voidprofileResults(ProfileShardResult shardResults)Sets the finalized profiling results for this queryQuerySearchResultqueryResult()Returns the query result iff it's included in this response otherwisenullvoidreadFromWithId(SearchContextId id, StreamInput in)booleansearchTimedOut()voidsearchTimedOut(boolean searchTimedOut)longserviceTimeEWMA()QuerySearchResultserviceTimeEWMA(long serviceTimeEWMA)intsize()Returns the maximum size of this results top docs.QuerySearchResultsize(int size)DocValueFormat[]sortValueFormats()Suggestsuggest()voidsuggest(Suggest suggest)java.lang.BooleanterminatedEarly()voidterminatedEarly(boolean terminatedEarly)TopDocsAndMaxScoretopDocs()voidtopDocs(TopDocsAndMaxScore topDocs, DocValueFormat[] sortValueFormats)voidwriteTo(StreamOutput out)Write this into the StreamOutput.voidwriteToNoId(StreamOutput out)Methods inherited from class org.elasticsearch.search.SearchPhaseResult
fetchResult, getContextId, getSearchShardTarget, getShardIndex, setSearchShardTarget, setShardIndexMethods inherited from class org.elasticsearch.transport.TransportMessage
remoteAddress, remoteAddress
-
Constructor Details
-
QuerySearchResult
public QuerySearchResult() -
QuerySearchResult
- Throws:
java.io.IOException
-
QuerySearchResult
-
-
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:SearchPhaseResultReturns the query result iff it's included in this response otherwisenull- Overrides:
queryResultin classSearchPhaseResult
-
searchTimedOut
public void searchTimedOut(boolean searchTimedOut) -
searchTimedOut
public boolean searchTimedOut() -
terminatedEarly
public void terminatedEarly(boolean terminatedEarly) -
terminatedEarly
public java.lang.Boolean terminatedEarly() -
topDocs
-
hasConsumedTopDocs
public boolean hasConsumedTopDocs()Returnstrueiff 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:
java.lang.IllegalStateException- if the top docs have already been consumed.
-
topDocs
-
sortValueFormats
-
hasAggs
public boolean hasAggs()Returnstrueif this query result has unconsumed aggregations -
consumeAggs
Returns and nulls out the aggregation for this search results. This allows to free up memory once the aggregation is consumed.- Throws:
java.lang.IllegalStateException- if the aggregations have already been consumed.
-
aggregations
-
aggregations
-
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:
java.lang.IllegalStateException- if the profiled result has already been consumed.
-
hasProfileResults
public boolean hasProfileResults() -
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()Returnstrueif this result has any suggest score docs -
hasSearchContext
public boolean hasSearchContext() -
readFromWithId
- Throws:
java.io.IOException
-
writeTo
Description copied from interface:WriteableWrite this into the StreamOutput.- Specified by:
writeToin interfaceWriteable- Overrides:
writeToin classSearchPhaseResult- Throws:
java.io.IOException
-
writeToNoId
- Throws:
java.io.IOException
-
getTotalHits
public org.apache.lucene.search.TotalHits getTotalHits() -
getMaxScore
public float getMaxScore()
-