delete.asciidoc 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. --
  2. :api: delete
  3. :request: DeleteRequest
  4. :response: DeleteResponse
  5. --
  6. [id="{upid}-{api}"]
  7. === Delete API
  8. [id="{upid}-{api}-request"]
  9. ==== Delete Request
  10. A +{request}+ has no arguments
  11. ["source","java",subs="attributes,callouts,macros"]
  12. --------------------------------------------------
  13. include-tagged::{doc-tests-file}[{api}-request]
  14. --------------------------------------------------
  15. <1> Index
  16. <2> Type
  17. <3> Document id
  18. ==== Optional arguments
  19. The following arguments can optionally be provided:
  20. ["source","java",subs="attributes,callouts,macros"]
  21. --------------------------------------------------
  22. include-tagged::{doc-tests-file}[{api}-request-routing]
  23. --------------------------------------------------
  24. <1> Routing value
  25. ["source","java",subs="attributes,callouts,macros"]
  26. --------------------------------------------------
  27. include-tagged::{doc-tests-file}[{api}-request-timeout]
  28. --------------------------------------------------
  29. <1> Timeout to wait for primary shard to become available as a `TimeValue`
  30. <2> Timeout to wait for primary shard to become available as a `String`
  31. ["source","java",subs="attributes,callouts,macros"]
  32. --------------------------------------------------
  33. include-tagged::{doc-tests-file}[{api}-request-refresh]
  34. --------------------------------------------------
  35. <1> Refresh policy as a `WriteRequest.RefreshPolicy` instance
  36. <2> Refresh policy as a `String`
  37. ["source","java",subs="attributes,callouts,macros"]
  38. --------------------------------------------------
  39. include-tagged::{doc-tests-file}[{api}-request-version]
  40. --------------------------------------------------
  41. <1> Version
  42. ["source","java",subs="attributes,callouts,macros"]
  43. --------------------------------------------------
  44. include-tagged::{doc-tests-file}[{api}-request-version-type]
  45. --------------------------------------------------
  46. <1> Version type
  47. include::../execution.asciidoc[]
  48. [id="{upid}-{api}-response"]
  49. ==== Delete Response
  50. The returned +{response}+ allows to retrieve information about the executed
  51. operation as follows:
  52. ["source","java",subs="attributes,callouts,macros"]
  53. --------------------------------------------------
  54. include-tagged::{doc-tests-file}[{api}-response]
  55. --------------------------------------------------
  56. <1> Handle the situation where number of successful shards is less than
  57. total shards
  58. <2> Handle the potential failures
  59. It is also possible to check whether the document was found or not:
  60. ["source","java",subs="attributes,callouts,macros"]
  61. --------------------------------------------------
  62. include-tagged::{doc-tests-file}[{api}-notfound]
  63. --------------------------------------------------
  64. <1> Do something if the document to be deleted was not found
  65. If there is a version conflict, an `ElasticsearchException` will
  66. be thrown:
  67. ["source","java",subs="attributes,callouts,macros"]
  68. --------------------------------------------------
  69. include-tagged::{doc-tests-file}[{api}-conflict]
  70. --------------------------------------------------
  71. <1> The raised exception indicates that a version conflict error was returned