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:
Streamable
,Writeable
,StatusToXContentObject
,ToXContent
,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 class
SearchResponse.Clusters
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.transport.TransportResponse
TransportResponse.Empty
-
Nested classes/interfaces inherited from interface org.elasticsearch.common.xcontent.ToXContent
ToXContent.DelegatingMapParams, ToXContent.MapParams, 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
Constructors Constructor Description SearchResponse()
SearchResponse(SearchResponseSections internalResponse, java.lang.String scrollId, int totalShards, int successfulShards, int skippedShards, long tookInMillis, ShardSearchFailure[] shardFailures, SearchResponse.Clusters clusters)
-
Method Summary
Modifier and Type Method Description static SearchResponse
fromXContent(XContentParser parser)
Aggregations
getAggregations()
SearchResponse.Clusters
getClusters()
Returns info about what clusters the search was executed against.int
getFailedShards()
The failed number of shards the search was executed on.SearchHits
getHits()
The search hits.int
getNumReducePhases()
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.String
getScrollId()
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.int
getSkippedShards()
The number of shards skipped due to pre-filteringint
getSuccessfulShards()
The successful number of shards the search was executed on.Suggest
getSuggest()
TimeValue
getTook()
How long the search took.int
getTotalShards()
The total number of shards the search was executed on.XContentBuilder
innerToXContent(XContentBuilder builder, ToXContent.Params params)
java.lang.Boolean
isTerminatedEarly()
Has the search operation terminated early due to reachingterminateAfter
boolean
isTimedOut()
Has the search operation timed out.void
readFrom(StreamInput in)
Set this object's fields from a StreamInput.void
scrollId(java.lang.String scrollId)
RestStatus
status()
Returns the REST status to make sure it is returned correctlyjava.lang.String
toString()
XContentBuilder
toXContent(XContentBuilder builder, ToXContent.Params params)
void
writeTo(StreamOutput out)
Write this object's fields to a 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.ToXContentObject
isFragment
-
-
-
-
Constructor Detail
-
SearchResponse
public SearchResponse()
-
SearchResponse
public SearchResponse(SearchResponseSections internalResponse, java.lang.String scrollId, int totalShards, int successfulShards, int skippedShards, long tookInMillis, ShardSearchFailure[] shardFailures, SearchResponse.Clusters clusters)
-
-
Method Detail
-
status
public RestStatus status()
Description copied from interface:StatusToXContentObject
Returns the REST status to make sure it is returned correctly- Specified by:
status
in interfaceStatusToXContentObject
-
getHits
public SearchHits getHits()
The search hits.
-
getAggregations
public Aggregations getAggregations()
-
getSuggest
public Suggest 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 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
public ShardSearchFailure[] 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.
-
scrollId
public void scrollId(java.lang.String scrollId)
-
getProfileResults
@Nullable public java.util.Map<java.lang.String,ProfileShardResult> 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
public SearchResponse.Clusters 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 XContentBuilder toXContent(XContentBuilder builder, ToXContent.Params params) throws java.io.IOException
- Specified by:
toXContent
in interfaceToXContent
- Throws:
java.io.IOException
-
innerToXContent
public XContentBuilder innerToXContent(XContentBuilder builder, ToXContent.Params params) throws java.io.IOException
- Throws:
java.io.IOException
-
fromXContent
public static SearchResponse fromXContent(XContentParser parser) throws java.io.IOException
- Throws:
java.io.IOException
-
readFrom
public void readFrom(StreamInput in) throws java.io.IOException
Description copied from interface:Streamable
Set this object's fields from a StreamInput.- Specified by:
readFrom
in interfaceStreamable
- Overrides:
readFrom
in classActionResponse
- Throws:
java.io.IOException
-
writeTo
public void writeTo(StreamOutput out) throws java.io.IOException
Description copied from interface:Streamable
Write this object's fields to a StreamOutput.- Specified by:
writeTo
in interfaceStreamable
- Specified by:
writeTo
in interfaceWriteable
- Overrides:
writeTo
in classActionResponse
- Throws:
java.io.IOException
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-