delete.asciidoc 3.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667
  1. [[java-rest-high-document-delete]]
  2. === Delete API
  3. [[java-rest-high-document-delete-request]]
  4. ==== Delete Request
  5. The most simple Delete Request needs is:
  6. ["source","java",subs="attributes,callouts"]
  7. --------------------------------------------------
  8. 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/documentation/DeleteDocumentationIT.java]
  9. --------------------------------------------------
  10. <1> Index name
  11. <2> Type
  12. <3> Document id
  13. You can also provide the following properties:
  14. ["source","java",subs="attributes,callouts"]
  15. --------------------------------------------------
  16. 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/documentation/DeleteDocumentationIT.java]
  17. --------------------------------------------------
  18. <1> Timeout
  19. <2> Timeout as String
  20. <3> Refresh policy
  21. <4> Refresh policy as String
  22. <5> Version
  23. <6> Version type
  24. [[java-rest-high-document-delete-sync]]
  25. ==== Execution
  26. ["source","java",subs="attributes,callouts"]
  27. --------------------------------------------------
  28. 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/documentation/DeleteDocumentationIT.java]
  29. --------------------------------------------------
  30. [[java-rest-high-document-delete-async]]
  31. ==== Asynchronous Execution
  32. ["source","java",subs="attributes,callouts"]
  33. --------------------------------------------------
  34. 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/documentation/DeleteDocumentationIT.java]
  35. --------------------------------------------------
  36. <1> Implement if needed when execution did not throw an exception
  37. <2> Implement if needed in case of failure
  38. [[java-rest-high-document-delete-response]]
  39. ==== Delete Response
  40. In the Delete Response object, you can check for example the result of the operation:
  41. ["source","java",subs="attributes,callouts"]
  42. --------------------------------------------------
  43. 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/documentation/DeleteDocumentationIT.java]
  44. --------------------------------------------------
  45. <1> Do something if we did not find the document which should have been deleted
  46. Note that if you have a version conflict because you defined the version within the
  47. <<java-rest-high-document-delete-request>>, it will raise an `ElasticsearchException` like:
  48. ["source","java",subs="attributes,callouts"]
  49. --------------------------------------------------
  50. sys2::[perl -ne 'exit if /end::delete-conflict/; print if $tag; $tag = $tag || /tag::delete-conflict/' {docdir}/../../client/rest-high-level/src/test/java/org/elasticsearch/client/documentation/DeleteDocumentationIT.java]
  51. --------------------------------------------------
  52. <1> We got a version conflict