Class AsyncSearchResponse

All Implemented Interfaces:
Writeable, ChunkedToXContent, ChunkedToXContentObject, org.elasticsearch.core.RefCounted, AsyncResponse<AsyncSearchResponse>

public class AsyncSearchResponse extends ActionResponse implements ChunkedToXContentObject, AsyncResponse<AsyncSearchResponse>
A response of an async search request.
  • Constructor Details

    • AsyncSearchResponse

      public AsyncSearchResponse(String id, boolean isPartial, boolean isRunning, long startTimeMillis, long expirationTimeMillis)
      Creates an AsyncSearchResponse with meta-information only (not-modified).
    • AsyncSearchResponse

      public AsyncSearchResponse(String id, SearchResponse searchResponse, Exception error, boolean isPartial, boolean isRunning, long startTimeMillis, long expirationTimeMillis)
      Creates a new AsyncSearchResponse
      Parameters:
      id - The id of the search for further retrieval, null if not stored.
      searchResponse - The actual search response.
      error - The error if the search failed, null if the search is running or has completed without failure.
      isPartial - Whether the searchResponse contains partial results.
      isRunning - Whether the search is running in the cluster.
      startTimeMillis - The start date of the search in milliseconds since epoch.
    • AsyncSearchResponse

      public AsyncSearchResponse(StreamInput in) throws IOException
      Throws:
      IOException
  • Method Details

    • writeTo

      public void writeTo(StreamOutput out) throws IOException
      Specified by:
      writeTo in interface Writeable
      Throws:
      IOException
    • incRef

      public void incRef()
      Specified by:
      incRef in interface org.elasticsearch.core.RefCounted
      Overrides:
      incRef in class TransportMessage
    • tryIncRef

      public boolean tryIncRef()
      Specified by:
      tryIncRef in interface org.elasticsearch.core.RefCounted
      Overrides:
      tryIncRef in class TransportMessage
    • decRef

      public boolean decRef()
      Specified by:
      decRef in interface org.elasticsearch.core.RefCounted
      Overrides:
      decRef in class TransportMessage
    • hasReferences

      public boolean hasReferences()
      Specified by:
      hasReferences in interface org.elasticsearch.core.RefCounted
      Overrides:
      hasReferences in class TransportMessage
    • clone

      public AsyncSearchResponse clone(String searchId)
    • getId

      @Nullable public String getId()
      Returns the id of the async search request or null if the response is not stored in the cluster.
    • getSearchResponse

      public SearchResponse getSearchResponse()
      Returns the current SearchResponse or null if not available. See isPartial() to determine whether the response contains partial or complete results.
    • getFailure

      public Exception getFailure()
      Returns the failure reason or null if the query is running or has completed normally.
    • isPartial

      public boolean isPartial()
      Returns true if the SearchResponse contains partial results computed from a subset of the total shards.
    • isRunning

      public boolean isRunning()
      Whether the search is still running in the cluster. A value of false indicates that the response is final even if isPartial() returns true. In such case, the partial response represents the status of the search before a non-recoverable failure.
    • getStartTime

      public long getStartTime()
      When this response was created as a timestamp in milliseconds since epoch.
    • getExpirationTime

      public long getExpirationTime()
      When this response will expired as a timestamp in milliseconds since epoch.
      Specified by:
      getExpirationTime in interface AsyncResponse<AsyncSearchResponse>
    • getCompletionTime

      public Long getCompletionTime()
      Returns:
      completion time in millis if the search is finished running. Otherwise it will return null;
    • withExpirationTime

      public AsyncSearchResponse withExpirationTime(long expirationTime)
      Description copied from interface: AsyncResponse
      Returns a copy of this object with a new expiration time
      Specified by:
      withExpirationTime in interface AsyncResponse<AsyncSearchResponse>
    • status

      public RestStatus status()
    • toXContentChunked

      public Iterator<? extends org.elasticsearch.xcontent.ToXContent> toXContentChunked(org.elasticsearch.xcontent.ToXContent.Params params)
      Specified by:
      toXContentChunked in interface ChunkedToXContent
    • convertToFailure

      public AsyncSearchResponse convertToFailure(Exception exc)
      Description copied from interface: AsyncResponse
      Convert this AsyncResponse to a new AsyncResponse with a given failure
      Specified by:
      convertToFailure in interface AsyncResponse<AsyncSearchResponse>
      Returns:
      a new AsyncResponse that stores a failure with a provided exception