Class SearchResponse

All Implemented Interfaces:
Writeable, StatusToXContentObject, org.elasticsearch.common.xcontent.ToXContent, org.elasticsearch.common.xcontent.ToXContentObject, org.elasticsearch.core.RefCounted

public class SearchResponse extends ActionResponse implements StatusToXContentObject
A response of a search request.
  • Constructor Details

  • Method Details

    • status

      public RestStatus status()
      Description copied from interface: StatusToXContentObject
      Returns the REST status to make sure it is returned correctly
      Specified by:
      status in interface StatusToXContentObject
    • getInternalResponse

      public SearchResponseSections getInternalResponse()
    • 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 Boolean isTerminatedEarly()
      Has the search operation terminated early due to reaching terminateAfter
    • 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

      public ShardSearchFailure[] getShardFailures()
      The failures that occurred during the search.
    • getScrollId

      public String getScrollId()
      If scrolling was enabled (SearchRequest.scroll(, the scroll id that can be used to continue scrolling.
    • pointInTimeId

      public String pointInTimeId()
      Returns the encoded string of the search context that the search request is used to executed
    • getProfileResults

      @Nullable public Map<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
      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, otherwise null
      See Also:
    • 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 interface org.elasticsearch.common.xcontent.ToXContent
    • innerToXContent

      public org.elasticsearch.common.xcontent.XContentBuilder innerToXContent(org.elasticsearch.common.xcontent.XContentBuilder builder, org.elasticsearch.common.xcontent.ToXContent.Params params) throws IOException
    • fromXContent

      public static SearchResponse fromXContent(org.elasticsearch.common.xcontent.XContentParser parser) throws IOException
    • innerFromXContent

      public static SearchResponse innerFromXContent(org.elasticsearch.common.xcontent.XContentParser parser) throws IOException
    • writeTo

      public void writeTo(StreamOutput out) throws IOException
      Description copied from interface: Writeable
      Write this into the StreamOutput.
      Specified by:
      writeTo in interface Writeable
    • toString

      public String toString()
      toString in class Object