java.lang.Object
org.elasticsearch.transport.TransportMessage
org.elasticsearch.transport.TransportResponse
org.elasticsearch.action.ActionResponse
org.elasticsearch.action.search.SearchResponse
- All Implemented Interfaces:
Writeable
,ChunkedToXContent
,ChunkedToXContentObject
,RefCounted
A response of a search request.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic class
Represents the search metadata about a particular cluster involved in a cross-cluster search.static final class
Holds info about the clusters that the search was executed on: how many in total, how many of them were successful and how many of them were skipped and further details in a Map of Cluster objects (when doing a cross-cluster search).Nested classes/interfaces inherited from class org.elasticsearch.action.ActionResponse
ActionResponse.Empty
Nested classes/interfaces inherited from interface org.elasticsearch.common.io.stream.Writeable
Writeable.Reader<V>, Writeable.Writer<V>
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
static final ParseField
static final ParseField
static final ParseField
static final ParseField
static final ParseField
static final ParseField
Fields inherited from interface org.elasticsearch.common.xcontent.ChunkedToXContent
EMPTY
Fields inherited from interface org.elasticsearch.core.RefCounted
ALWAYS_REFERENCED
-
Constructor Summary
ConstructorDescriptionSearchResponse
(SearchResponseSections searchResponseSections, String scrollId, int totalShards, int successfulShards, int skippedShards, long tookInMillis, ShardSearchFailure[] shardFailures, SearchResponse.Clusters clusters, String pointInTimeId) SearchResponse
(SearchHits hits, InternalAggregations aggregations, Suggest suggest, boolean timedOut, Boolean terminatedEarly, SearchProfileResults profileResults, int numReducePhases, String scrollId, int totalShards, int successfulShards, int skippedShards, long tookInMillis, ShardSearchFailure[] shardFailures, SearchResponse.Clusters clusters) SearchResponse
(SearchHits hits, InternalAggregations aggregations, Suggest suggest, boolean timedOut, Boolean terminatedEarly, SearchProfileResults profileResults, int numReducePhases, String scrollId, int totalShards, int successfulShards, int skippedShards, long tookInMillis, ShardSearchFailure[] shardFailures, SearchResponse.Clusters clusters, String pointInTimeId) -
Method Summary
Modifier and TypeMethodDescriptionboolean
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.static SearchResponse
empty
(Supplier<Long> tookInMillisSupplier, SearchResponse.Clusters clusters) Aggregations in this response.Returns info about what clusters the search was executed against.int
The failed number of shards the search was executed on.getHits()
The search hits.int
Returns the number of reduce phases applied to obtain this search responseIf profiling was enabled, this returns an object containing the profile results from each shard.If scrolling was enabled (SearchRequest.scroll(org.elasticsearch.search.Scroll)
, the scroll id that can be used to continue scrolling.The failures that occurred during the search.int
The number of shards skipped due to pre-filteringint
The successful number of shards the search was executed on.getTook()
How long the search took.long
int
The total number of shards the search was executed on.boolean
WillgetAggregations()
return non-empty aggregation results?boolean
headerToXContent
(XContentBuilder builder, ToXContent.Params params) void
incRef()
Iterator<? extends ToXContent>
Has the search operation terminated early due to reachingterminateAfter
boolean
Has the search operation timed out.Returns the encoded string of the search context that the search request is used to executedstatus()
toString()
Iterator<? extends ToXContent>
toXContentChunked
(ToXContent.Params params) Create an iterator ofToXContent
chunks for a REST response.boolean
void
writeTo
(StreamOutput out) Write this into the StreamOutput.Methods inherited from class org.elasticsearch.transport.TransportMessage
remoteAddress, remoteAddress
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
Methods inherited from interface org.elasticsearch.common.xcontent.ChunkedToXContent
toXContentChunkedV7
Methods inherited from interface org.elasticsearch.common.xcontent.ChunkedToXContentObject
isFragment
Methods inherited from interface org.elasticsearch.core.RefCounted
mustIncRef
-
Field Details
-
LOCAL_CLUSTER_NAME_REPRESENTATION
- See Also:
-
SCROLL_ID
-
POINT_IN_TIME_ID
-
TOOK
-
TIMED_OUT
-
TERMINATED_EARLY
-
NUM_REDUCE_PHASES
-
-
Constructor Details
-
SearchResponse
- Throws:
IOException
-
SearchResponse
public SearchResponse(SearchHits hits, InternalAggregations aggregations, Suggest suggest, boolean timedOut, Boolean terminatedEarly, SearchProfileResults profileResults, int numReducePhases, String scrollId, int totalShards, int successfulShards, int skippedShards, long tookInMillis, ShardSearchFailure[] shardFailures, SearchResponse.Clusters clusters) -
SearchResponse
public SearchResponse(SearchResponseSections searchResponseSections, String scrollId, int totalShards, int successfulShards, int skippedShards, long tookInMillis, ShardSearchFailure[] shardFailures, SearchResponse.Clusters clusters, String pointInTimeId) -
SearchResponse
public SearchResponse(SearchHits hits, InternalAggregations aggregations, Suggest suggest, boolean timedOut, Boolean terminatedEarly, SearchProfileResults profileResults, int numReducePhases, String scrollId, int totalShards, int successfulShards, int skippedShards, long tookInMillis, ShardSearchFailure[] shardFailures, SearchResponse.Clusters clusters, String pointInTimeId)
-
-
Method Details
-
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
-
status
-
getHits
The search hits. -
getAggregations
Aggregations in this response. "empty" aggregations could be eithernull
orInternalAggregations.EMPTY
. -
hasAggregations
public boolean hasAggregations()WillgetAggregations()
return non-empty aggregation results? -
getSuggest
-
isTimedOut
public boolean isTimedOut()Has the search operation timed out. -
isTerminatedEarly
Has the search operation terminated early due to reachingterminateAfter
-
getNumReducePhases
public int getNumReducePhases()Returns the number of reduce phases applied to obtain this search response -
getTook
How long the search took. -
getTookInMillis
public long getTookInMillis() -
getTotalShards
public int getTotalShards()The total number of shards the search was executed on. -
getSuccessfulShards
public int getSuccessfulShards()The successful number of shards the search was executed on. -
getSkippedShards
public int getSkippedShards()The number of shards skipped due to pre-filtering -
getFailedShards
public int getFailedShards()The failed number of shards the search was executed on. -
getShardFailures
The failures that occurred during the search. -
getScrollId
If scrolling was enabled (SearchRequest.scroll(org.elasticsearch.search.Scroll)
, the scroll id that can be used to continue scrolling. -
pointInTimeId
Returns the encoded string of the search context that the search request is used to executed -
getProfileResults
If profiling was enabled, this returns an object containing the profile results from each shard. If profiling was not enabled, this will return null- Returns:
- The profile results or an empty map
-
getClusters
Returns info about what clusters the search was executed against. Available only in responses obtained from a Cross Cluster Search request, otherwisenull
- See Also:
-
toXContentChunked
Description copied from interface:ChunkedToXContent
Create an iterator ofToXContent
chunks for a REST response. Each chunk is serialized with the sameXContentBuilder
andToXContent.Params
, which is also the same as theToXContent.Params
passed as theparams
argument. For best results, all chunks should beO(1)
size. The last chunk in the iterator must always yield at least one byte of output. See alsoChunkedToXContentHelper
for some handy utilities.Note that chunked response bodies cannot send deprecation warning headers once transmission has started, so implementations must check for deprecated feature use before returning.
- Specified by:
toXContentChunked
in interfaceChunkedToXContent
- Returns:
- iterator over chunks of
ToXContent
-
innerToXContentChunked
-
headerToXContent
public XContentBuilder headerToXContent(XContentBuilder builder, ToXContent.Params params) throws IOException - Throws:
IOException
-
writeTo
Description copied from interface:Writeable
Write this into the StreamOutput.- Specified by:
writeTo
in interfaceWriteable
- Throws:
IOException
-
toString
-
empty
public static SearchResponse empty(Supplier<Long> tookInMillisSupplier, SearchResponse.Clusters clusters)
-