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
public class SearchResponse extends ActionResponse implements StatusToXContentObject
A response of a search request.
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classSearchResponse.ClustersHolds 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.transport.TransportResponse
TransportResponse.EmptyNested 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.ParamsNested classes/interfaces inherited from interface org.elasticsearch.common.io.stream.Writeable
Writeable.Reader<V>, Writeable.Writer<V> -
Field Summary
-
Constructor Summary
Constructors Constructor Description SearchResponse(SearchResponseSections internalResponse, java.lang.String scrollId, int totalShards, int successfulShards, int skippedShards, long tookInMillis, ShardSearchFailure[] shardFailures, SearchResponse.Clusters clusters)SearchResponse(StreamInput in) -
Method Summary
Modifier and Type Method Description static SearchResponsefromXContent(org.elasticsearch.common.xcontent.XContentParser parser)AggregationsgetAggregations()SearchResponse.ClustersgetClusters()Returns info about what clusters the search was executed against.intgetFailedShards()The failed number of shards the search was executed on.SearchHitsgetHits()The search hits.SearchResponseSectionsgetInternalResponse()intgetNumReducePhases()Returns the number of reduce phases applied to obtain this search responsejava.util.Map<java.lang.String,ProfileShardResult>getProfileResults()If profiling was enabled, this returns an object containing the profile results from each shard.java.lang.StringgetScrollId()If scrolling was enabled (SearchRequest.scroll(org.elasticsearch.search.Scroll), the scroll id that can be used to continue scrolling.ShardSearchFailure[]getShardFailures()The failures that occurred during the search.intgetSkippedShards()The number of shards skipped due to pre-filteringintgetSuccessfulShards()The successful number of shards the search was executed on.SuggestgetSuggest()org.elasticsearch.common.unit.TimeValuegetTook()How long the search took.intgetTotalShards()The total number of shards the search was executed on.static SearchResponseinnerFromXContent(org.elasticsearch.common.xcontent.XContentParser parser)org.elasticsearch.common.xcontent.XContentBuilderinnerToXContent(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.xcontent.ToXContent.Params params)java.lang.BooleanisTerminatedEarly()Has the search operation terminated early due to reachingterminateAfterbooleanisTimedOut()Has the search operation timed out.RestStatusstatus()Returns the REST status to make sure it is returned correctlyjava.lang.StringtoString()org.elasticsearch.common.xcontent.XContentBuildertoXContent(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.xcontent.ToXContent.Params params)voidwriteTo(StreamOutput out)Write this into the StreamOutput.Methods inherited from class org.elasticsearch.transport.TransportMessage
remoteAddress, remoteAddress
-
Constructor Details
-
SearchResponse
- Throws:
java.io.IOException
-
SearchResponse
public SearchResponse(SearchResponseSections internalResponse, java.lang.String scrollId, int totalShards, int successfulShards, int skippedShards, long tookInMillis, ShardSearchFailure[] shardFailures, SearchResponse.Clusters clusters)
-
-
Method Details
-
status
Description copied from interface:StatusToXContentObjectReturns the REST status to make sure it is returned correctly- Specified by:
statusin interfaceStatusToXContentObject
-
getInternalResponse
-
getHits
The search hits. -
getAggregations
-
getSuggest
-
isTimedOut
public boolean isTimedOut()Has the search operation timed out. -
isTerminatedEarly
public java.lang.Boolean 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.common.unit.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
public java.lang.String getScrollId()If scrolling was enabled (SearchRequest.scroll(org.elasticsearch.search.Scroll), the scroll id that can be used to continue scrolling. -
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 java.io.IOException- Specified by:
toXContentin interfaceorg.elasticsearch.common.xcontent.ToXContent- Throws:
java.io.IOException
-
innerToXContent
public org.elasticsearch.common.xcontent.XContentBuilder innerToXContent(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.xcontent.ToXContent.Params params) throws java.io.IOException- Throws:
java.io.IOException
-
fromXContent
public static SearchResponse fromXContent(org.elasticsearch.common.xcontent.XContentParser parser) throws java.io.IOException- Throws:
java.io.IOException
-
innerFromXContent
public static SearchResponse innerFromXContent(org.elasticsearch.common.xcontent.XContentParser parser) throws java.io.IOException- Throws:
java.io.IOException
-
writeTo
Description copied from interface:WriteableWrite this into the StreamOutput. -
toString
public java.lang.String toString()- Overrides:
toStringin classjava.lang.Object
-