Delete API

    1. request.parent("parent"); //Parent 值
    2. request.timeout(TimeValue.timeValueMinutes(2)); // TimeValue 类型的等待主分片可用的超时时间
    3. request.setRefreshPolicy(WriteRequest.RefreshPolicy.WAIT_UNTIL); // Refresh policy as a WriteRequest.RefreshPolicy instance
    4. request.setRefreshPolicy("wait_for"); // Refresh policy as a String
    5. request.version(2); // Version
    1. client.deleteAsync(request, new ActionListener<DeleteResponse>() {
    2. @Override
    3. public void onResponse(DeleteResponse deleteResponse) {
    4. //Called when the execution is successfully completed. The response is provided as an argument
    5. @Override
    6. //Called in case of failure. The raised exception is provided as an argument
    7. }
    8. });
    1. DeleteRequest request = new DeleteRequest("posts", "doc", "does_not_exist");
    2. DeleteResponse deleteResponse = client.delete(request);
    3. if (deleteResponse.getResult() == DocWriteResponse.Result.NOT_FOUND) {
    4. }