|
@@ -6,12 +6,9 @@
|
|
|
|
|
|
The most simple Delete Request needs is:
|
|
|
|
|
|
-[source,java]
|
|
|
+["source","java",subs="attributes,callouts"]
|
|
|
--------------------------------------------------
|
|
|
-DeleteRequest request = new DeleteRequest(
|
|
|
- "index", <1>
|
|
|
- "type", <2>
|
|
|
- "id"); <3>
|
|
|
+sys2::[perl -ne 'exit if /end::delete-request/; print if $tag; $tag = $tag || /tag::delete-request/' {docdir}/../../client/rest-high-level/src/test/java/org/elasticsearch/client/DocumentationIT.java]
|
|
|
--------------------------------------------------
|
|
|
<1> Index name
|
|
|
<2> Type
|
|
@@ -19,14 +16,9 @@ DeleteRequest request = new DeleteRequest(
|
|
|
|
|
|
You can also provide the following properties:
|
|
|
|
|
|
-[source,java]
|
|
|
+["source","java",subs="attributes,callouts"]
|
|
|
--------------------------------------------------
|
|
|
-request.timeout(TimeValue.timeValueSeconds(1)); <1>
|
|
|
-request.timeout("1s"); <2>
|
|
|
-request.setRefreshPolicy(WriteRequest.RefreshPolicy.WAIT_UNTIL); <3>
|
|
|
-request.setRefreshPolicy("wait_for"); <4>
|
|
|
-request.version(2); <5>
|
|
|
-request.versionType(VersionType.EXTERNAL); <6>
|
|
|
+sys2::[perl -ne 'exit if /end::delete-request-props/; print if $tag; $tag = $tag || /tag::delete-request-props/' {docdir}/../../client/rest-high-level/src/test/java/org/elasticsearch/client/DocumentationIT.java]
|
|
|
--------------------------------------------------
|
|
|
<1> Timeout
|
|
|
<2> Timeout as String
|
|
@@ -38,27 +30,17 @@ request.versionType(VersionType.EXTERNAL); <6>
|
|
|
[[java-rest-high-document-delete-sync]]
|
|
|
==== Execution
|
|
|
|
|
|
-[source,java]
|
|
|
+["source","java",subs="attributes,callouts"]
|
|
|
--------------------------------------------------
|
|
|
-DeleteResponse response = client.delete(request);
|
|
|
+sys2::[perl -ne 'exit if /end::delete-execute/; print if $tag; $tag = $tag || /tag::delete-execute/' {docdir}/../../client/rest-high-level/src/test/java/org/elasticsearch/client/DocumentationIT.java]
|
|
|
--------------------------------------------------
|
|
|
|
|
|
[[java-rest-high-document-delete-async]]
|
|
|
==== Asynchronous Execution
|
|
|
|
|
|
-[source,java]
|
|
|
+["source","java",subs="attributes,callouts"]
|
|
|
--------------------------------------------------
|
|
|
-client.deleteAsync(request, new ActionListener<DeleteResponse>() {
|
|
|
- @Override
|
|
|
- public void onResponse(DeleteResponse deleteResponse) {
|
|
|
- <1>
|
|
|
- }
|
|
|
-
|
|
|
- @Override
|
|
|
- public void onFailure(Exception e) {
|
|
|
- <2>
|
|
|
- }
|
|
|
-});
|
|
|
+sys2::[perl -ne 'exit if /end::delete-execute-async/; print if $tag; $tag = $tag || /tag::delete-execute-async/' {docdir}/../../client/rest-high-level/src/test/java/org/elasticsearch/client/DocumentationIT.java]
|
|
|
--------------------------------------------------
|
|
|
<1> Implement if needed when execution did not throw an exception
|
|
|
<2> Implement if needed in case of failure
|
|
@@ -68,11 +50,9 @@ client.deleteAsync(request, new ActionListener<DeleteResponse>() {
|
|
|
|
|
|
In the Delete Response object, you can check for example the result of the operation:
|
|
|
|
|
|
-[source,java]
|
|
|
+["source","java",subs="attributes,callouts"]
|
|
|
--------------------------------------------------
|
|
|
-if (response.getResult().equals(DocWriteResponse.Result.NOT_FOUND)) {
|
|
|
- <1>
|
|
|
-}
|
|
|
+sys2::[perl -ne 'exit if /end::delete-notfound/; print if $tag; $tag = $tag || /tag::delete-notfound/' {docdir}/../../client/rest-high-level/src/test/java/org/elasticsearch/client/DocumentationIT.java]
|
|
|
--------------------------------------------------
|
|
|
<1> Do something if we did not find the document which should have been deleted
|
|
|
|
|
@@ -90,3 +70,4 @@ try {
|
|
|
}
|
|
|
--------------------------------------------------
|
|
|
<1> We got a version conflict
|
|
|
+
|