企业🤖AI智能体构建引擎,智能编排和调试,一键部署,支持私有化部署方案 广告
## 删除请求 ``` DeleteRequest request = new DeleteRequest( "posts", "1"); ``` ### 可选参数 ``` request.routing("routing"); request.timeout(TimeValue.timeValueMinutes(2)); request.timeout("2m"); request.setRefreshPolicy(WriteRequest.RefreshPolicy.WAIT_UNTIL); request.setRefreshPolicy("wait_for"); request.version(2); request.versionType(VersionType.EXTERNAL); ``` 同步请求 ``` DeleteResponse deleteResponse = client.delete( request, RequestOptions.DEFAULT); ``` 异步请求 ``` client.deleteAsync(request, RequestOptions.DEFAULT, listener); ``` ``` listener = new ActionListener<DeleteResponse>() { @Override public void onResponse(DeleteResponse deleteResponse) { } @Override public void onFailure(Exception e) { } }; ``` delete response ``` String index = deleteResponse.getIndex(); String id = deleteResponse.getId(); long version = deleteResponse.getVersion(); ReplicationResponse.ShardInfo shardInfo = deleteResponse.getShardInfo(); if (shardInfo.getTotal() != shardInfo.getSuccessful()) { } if (shardInfo.getFailed() > 0) { for (ReplicationResponse.ShardInfo.Failure failure : shardInfo.getFailures()) { String reason = failure.reason(); } } ```