delete.asciidoc 3.0 KB

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