Delete Async Search APIedit

Requestedit

A DeleteAsyncSearchRequest allows deleting a running asynchronous search task using its id. Required arguments are the id of a running search:

DeleteAsyncSearchRequest request = new DeleteAsyncSearchRequest(id);

Synchronous Executionedit

AcknowledgedResponse response = client.asyncSearch() 
        .delete(new DeleteAsyncSearchRequest(id),
                RequestOptions.DEFAULT);

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

Asynchronous Executionedit

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

client.asyncSearch()
    .deleteAsync(request, RequestOptions.DEFAULT, listener);  

The DeleteAsyncSearchRequest 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 AcknowledgedResponse looks like:

ActionListener<AcknowledgedResponse> listener =
    new ActionListener<AcknowledgedResponse>() {
        @Override
        public void onResponse(AcknowledgedResponse response) {
            
        }

        @Override
        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

Responseedit

The returned AcknowledgedResponse indicates the acknowledgement of the request:

response.isAcknowledged(); 

isAcknowledged was the deletion request acknowledged or not.