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
Nested ClassesModifier and TypeClassDescriptionstatic classRepresents the search metadata about a particular cluster involved in a cross-cluster search.static final classHolds 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.EmptyNested classes/interfaces inherited from interface org.elasticsearch.common.io.stream.Writeable
Writeable.Reader<V>, Writeable.Writer<V> -
Field Summary
FieldsModifier and TypeFieldDescriptionstatic final Stringstatic final ParseFieldstatic final ParseFieldstatic final ParseFieldstatic final ParseFieldstatic final ParseFieldstatic final ParseFieldFields inherited from interface org.elasticsearch.common.xcontent.ChunkedToXContent
EMPTYFields inherited from interface org.elasticsearch.core.RefCounted
ALWAYS_REFERENCED -
Constructor Summary
ConstructorsConstructorDescriptionSearchResponse(SearchResponseSections searchResponseSections, String scrollId, int totalShards, int successfulShards, int skippedShards, long tookInMillis, ShardSearchFailure[] shardFailures, SearchResponse.Clusters clusters, BytesReference 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, BytesReference pointInTimeId) -
Method Summary
Modifier and TypeMethodDescriptionbooleandecRef()Note that the lifetime of an outboundTransportMessagelasts 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 SearchResponseempty(Supplier<Long> tookInMillisSupplier, SearchResponse.Clusters clusters) Aggregations in this response.Returns info about what clusters the search was executed against.intThe failed number of shards the search was executed on.getHits()The search hits.intReturns 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(TimeValue), the scroll id that can be used to continue scrolling.The failures that occurred during the search.intThe number of shards skipped due to pre-filteringintThe successful number of shards the search was executed on.getTook()How long the search took.longintThe total number of shards the search was executed on.booleanWillgetAggregations()return non-empty aggregation results?booleanheaderToXContent(XContentBuilder builder, ToXContent.Params params) voidincRef()Iterator<? extends ToXContent> Has the search operation terminated early due to reachingterminateAfterbooleanHas 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 ofToXContentchunks for a REST response.booleanvoidwriteTo(StreamOutput out) Write this into the StreamOutput.Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitMethods inherited from interface org.elasticsearch.common.xcontent.ChunkedToXContent
toXContentChunked, toXContentChunkedV8Methods inherited from interface org.elasticsearch.common.xcontent.ChunkedToXContentObject
isFragmentMethods 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, BytesReference 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, BytesReference pointInTimeId)
-
-
Method Details
-
incRef
public void incRef()- Specified by:
incRefin interfaceRefCounted- Overrides:
incRefin classTransportMessage
-
tryIncRef
public boolean tryIncRef()- Specified by:
tryIncRefin interfaceRefCounted- Overrides:
tryIncRefin classTransportMessage
-
decRef
public boolean decRef()Description copied from class:TransportMessageNote that the lifetime of an outboundTransportMessagelasts 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:
decRefin interfaceRefCounted- Overrides:
decRefin classTransportMessage
-
hasReferences
public boolean hasReferences()- Specified by:
hasReferencesin interfaceRefCounted- Overrides:
hasReferencesin classTransportMessage
-
status
-
getHits
The search hits. -
getAggregations
Aggregations in this response. "empty" aggregations could be eithernullorInternalAggregations.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(TimeValue), 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:ChunkedToXContentCreate an iterator ofToXContentchunks for a REST response. Each chunk is serialized with the sameXContentBuilderandToXContent.Params, which is also the same as theToXContent.Paramspassed as theparamsargument. 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 alsoChunkedToXContentHelperfor 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:
toXContentChunkedin 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:WriteableWrite this into the StreamOutput.- Specified by:
writeToin interfaceWriteable- Throws:
IOException
-
toString
-
empty
public static SearchResponse empty(Supplier<Long> tookInMillisSupplier, SearchResponse.Clusters clusters)
-