Module org.elasticsearch.xcore
Class AsyncSearchResponse
java.lang.Object
org.elasticsearch.transport.TransportMessage
org.elasticsearch.transport.TransportResponse
org.elasticsearch.action.ActionResponse
org.elasticsearch.xpack.core.search.action.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.
-
Nested Class Summary
Nested classes/interfaces inherited from class org.elasticsearch.action.ActionResponse
ActionResponse.EmptyNested 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.ChunkedToXContent
EMPTYFields inherited from interface org.elasticsearch.core.RefCounted
ALWAYS_REFERENCED -
Constructor Summary
ConstructorsConstructorDescriptionAsyncSearchResponse(String id, boolean isPartial, boolean isRunning, long startTimeMillis, long expirationTimeMillis) Creates anAsyncSearchResponsewith meta-information only (not-modified).AsyncSearchResponse(String id, SearchResponse searchResponse, Exception error, boolean isPartial, boolean isRunning, long startTimeMillis, long expirationTimeMillis) Creates a newAsyncSearchResponse -
Method Summary
Modifier and TypeMethodDescriptionConvert this AsyncResponse to a new AsyncResponse with a given failurebooleandecRef()longWhen this response will expired as a timestamp in milliseconds since epoch.Returns the failure reason or null if the query is running or has completed normally.getId()Returns the id of the async search request or null if the response is not stored in the cluster.Returns the currentSearchResponseornullif not available.longWhen this response was created as a timestamp in milliseconds since epoch.booleanvoidincRef()booleanReturnstrueif theSearchResponsecontains partial results computed from a subset of the total shards.booleanWhether the search is still running in the cluster.status()Iterator<? extends org.elasticsearch.xcontent.ToXContent> toXContentChunked(org.elasticsearch.xcontent.ToXContent.Params params) booleanwithExpirationTime(long expirationTime) Returns a copy of this object with a new expiration timevoidwriteTo(StreamOutput out) Methods inherited from class org.elasticsearch.transport.TransportMessage
remoteAddress, remoteAddressMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.elasticsearch.common.xcontent.ChunkedToXContent
toXContentChunkedV7Methods inherited from interface org.elasticsearch.common.xcontent.ChunkedToXContentObject
isFragmentMethods inherited from interface org.elasticsearch.core.RefCounted
mustIncRef
-
Constructor Details
-
AsyncSearchResponse
public AsyncSearchResponse(String id, boolean isPartial, boolean isRunning, long startTimeMillis, long expirationTimeMillis) Creates anAsyncSearchResponsewith meta-information only (not-modified). -
AsyncSearchResponse
public AsyncSearchResponse(String id, SearchResponse searchResponse, Exception error, boolean isPartial, boolean isRunning, long startTimeMillis, long expirationTimeMillis) Creates a newAsyncSearchResponse- Parameters:
id- The id of the search for further retrieval,nullif not stored.searchResponse- The actual search response.error- The error if the search failed,nullif the search is running or has completed without failure.isPartial- Whether thesearchResponsecontains partial results.isRunning- Whether the search is running in the cluster.startTimeMillis- The start date of the search in milliseconds since epoch.
-
AsyncSearchResponse
- Throws:
IOException
-
-
Method Details
-
writeTo
- Specified by:
writeToin interfaceWriteable- Throws:
IOException
-
incRef
public void incRef()- Specified by:
incRefin interfaceorg.elasticsearch.core.RefCounted- Overrides:
incRefin classTransportMessage
-
tryIncRef
public boolean tryIncRef()- Specified by:
tryIncRefin interfaceorg.elasticsearch.core.RefCounted- Overrides:
tryIncRefin classTransportMessage
-
decRef
public boolean decRef()- Specified by:
decRefin interfaceorg.elasticsearch.core.RefCounted- Overrides:
decRefin classTransportMessage
-
hasReferences
public boolean hasReferences()- Specified by:
hasReferencesin interfaceorg.elasticsearch.core.RefCounted- Overrides:
hasReferencesin classTransportMessage
-
clone
-
getId
Returns the id of the async search request or null if the response is not stored in the cluster. -
getSearchResponse
Returns the currentSearchResponseornullif not available. SeeisPartial()to determine whether the response contains partial or complete results. -
getFailure
Returns the failure reason or null if the query is running or has completed normally. -
isPartial
public boolean isPartial()Returnstrueif theSearchResponsecontains 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 offalseindicates that the response is final even ifisPartial()returnstrue. 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:
getExpirationTimein interfaceAsyncResponse<AsyncSearchResponse>
-
getCompletionTime
- Returns:
- completion time in millis if the search is finished running. Otherwise it will return null;
-
withExpirationTime
Description copied from interface:AsyncResponseReturns a copy of this object with a new expiration time- Specified by:
withExpirationTimein interfaceAsyncResponse<AsyncSearchResponse>
-
status
-
toXContentChunked
public Iterator<? extends org.elasticsearch.xcontent.ToXContent> toXContentChunked(org.elasticsearch.xcontent.ToXContent.Params params) - Specified by:
toXContentChunkedin interfaceChunkedToXContent
-
convertToFailure
Description copied from interface:AsyncResponseConvert this AsyncResponse to a new AsyncResponse with a given failure- Specified by:
convertToFailurein interfaceAsyncResponse<AsyncSearchResponse>- Returns:
- a new AsyncResponse that stores a failure with a provided exception
-