Package org.elasticsearch.action.search
Class SearchResponse
java.lang.Object
org.elasticsearch.transport.TransportMessage
org.elasticsearch.transport.TransportResponse
org.elasticsearch.action.ActionResponse
org.elasticsearch.action.search.SearchResponse
- All Implemented Interfaces:
Writeable
,StatusToXContentObject
,org.elasticsearch.common.xcontent.ToXContent
,org.elasticsearch.common.xcontent.ToXContentObject
,org.elasticsearch.core.RefCounted
A response of a search request.
-
Nested Class Summary
Modifier and TypeClassDescriptionstatic 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.Nested classes/interfaces inherited from class org.elasticsearch.action.ActionResponse
ActionResponse.Empty
Nested classes/interfaces inherited from interface org.elasticsearch.common.xcontent.ToXContent
org.elasticsearch.common.xcontent.ToXContent.DelegatingMapParams, org.elasticsearch.common.xcontent.ToXContent.MapParams, org.elasticsearch.common.xcontent.ToXContent.Params
Nested classes/interfaces inherited from interface org.elasticsearch.common.io.stream.Writeable
Writeable.Reader<V>, Writeable.Writer<V>
-
Field Summary
Fields inherited from interface org.elasticsearch.common.xcontent.ToXContent
EMPTY_PARAMS
-
Constructor Summary
ConstructorDescriptionSearchResponse(SearchResponseSections internalResponse, String scrollId, int totalShards, int successfulShards, int skippedShards, long tookInMillis, ShardSearchFailure[] shardFailures, SearchResponse.Clusters clusters)
SearchResponse(SearchResponseSections internalResponse, String scrollId, int totalShards, int successfulShards, int skippedShards, long tookInMillis, ShardSearchFailure[] shardFailures, SearchResponse.Clusters clusters, String pointInTimeId)
-
Method Summary
Modifier and TypeMethodDescriptionstatic SearchResponse
fromXContent(org.elasticsearch.common.xcontent.XContentParser parser)
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.org.elasticsearch.core.TimeValue
getTook()
How long the search took.int
The total number of shards the search was executed on.static SearchResponse
innerFromXContent(org.elasticsearch.common.xcontent.XContentParser parser)
org.elasticsearch.common.xcontent.XContentBuilder
innerToXContent(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.xcontent.ToXContent.Params params)
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()
Returns the REST status to make sure it is returned correctlytoString()
org.elasticsearch.common.xcontent.XContentBuilder
toXContent(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.xcontent.ToXContent.Params params)
void
writeTo(StreamOutput out)
Write this into the StreamOutput.Methods inherited from class org.elasticsearch.transport.TransportMessage
decRef, incRef, remoteAddress, remoteAddress, tryIncRef
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.ToXContentObject
isFragment
-
Constructor Details
-
SearchResponse
- Throws:
IOException
-
SearchResponse
public SearchResponse(SearchResponseSections internalResponse, String scrollId, int totalShards, int successfulShards, int skippedShards, long tookInMillis, ShardSearchFailure[] shardFailures, SearchResponse.Clusters clusters) -
SearchResponse
public SearchResponse(SearchResponseSections internalResponse, String scrollId, int totalShards, int successfulShards, int skippedShards, long tookInMillis, ShardSearchFailure[] shardFailures, SearchResponse.Clusters clusters, String pointInTimeId)
-
-
Method Details
-
status
Description copied from interface:StatusToXContentObject
Returns the REST status to make sure it is returned correctly- Specified by:
status
in interfaceStatusToXContentObject
-
getInternalResponse
-
getHits
The search hits. -
getAggregations
-
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
public org.elasticsearch.core.TimeValue getTook()How long the search took. -
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:
SearchResponse.Clusters
-
toXContent
public org.elasticsearch.common.xcontent.XContentBuilder toXContent(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.xcontent.ToXContent.Params params) throws IOException- Specified by:
toXContent
in interfaceorg.elasticsearch.common.xcontent.ToXContent
- Throws:
IOException
-
innerToXContent
public org.elasticsearch.common.xcontent.XContentBuilder innerToXContent(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.xcontent.ToXContent.Params params) throws IOException- Throws:
IOException
-
fromXContent
public static SearchResponse fromXContent(org.elasticsearch.common.xcontent.XContentParser parser) throws IOException- Throws:
IOException
-
innerFromXContent
public static SearchResponse innerFromXContent(org.elasticsearch.common.xcontent.XContentParser parser) throws IOException- Throws:
IOException
-
writeTo
Description copied from interface:Writeable
Write this into the StreamOutput.- Specified by:
writeTo
in interfaceWriteable
- Throws:
IOException
-
toString
-