Get Async Search APIedit


A GetAsyncSearchRequest allows to get a running asynchronous search task by its id. Required arguments are the id of a running async search:

GetAsyncSearchRequest request = new GetAsyncSearchRequest(id);

Optional argumentsedit

The following arguments can optionally be provided:


The minimum time that the request should wait before returning a partial result (defaults to no wait).

The expiration time of the request (defaults to none).

Synchronous Executionedit

AsyncSearchResponse response = client.asyncSearch()
        .get(request, RequestOptions.DEFAULT); 

Execute the request and get back the response as an AsyncSearchResponse object.

Asynchronous Executionedit

The asynchronous execution of a GetAsyncSearchRequest allows to use an ActionListener to be called back when the submit request returns:

    .getAsync(request, RequestOptions.DEFAULT, listener);  

The GetAsyncSearchRequest to execute and the ActionListener to use when the execution completes

The asynchronous method does not block and returns immediately. Once it is completed the ActionListener is called back using the onResponse method if the execution successfully completed or using the onFailure method if it failed.

A typical listener for AsyncSearchResponse looks like:

ActionListener<AsyncSearchResponse> listener =
    new ActionListener<AsyncSearchResponse>() {
        public void onResponse(AsyncSearchResponse response) {

        public void onFailure(Exception e) {

Called when the execution is successfully completed. The response is provided as an argument

Called in case of failure. The raised exception is provided as an argument


The returned AsyncSearchResponse allows to retrieve information about the executed operation as follows:


The SearchResponse, or null if not available yet

The id of the async search request, null if the response isn’t stored

true when the response contains partial results

true when the search is still running

The time the response was created (millis since epoch)

The time the response expires (millis since epoch)

Get failure reasons or null for no failures