delete_index.asciidoc 4.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. [[java-rest-high-delete-index]]
  2. === Delete Index API
  3. [[java-rest-high-delete-index-request]]
  4. ==== Delete Index Request
  5. A `DeleteIndexRequest` requires an `index` argument:
  6. ["source","java",subs="attributes,callouts,macros"]
  7. --------------------------------------------------
  8. include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[delete-index-request]
  9. --------------------------------------------------
  10. <1> Index
  11. ==== Optional arguments
  12. The following arguments can optionally be provided:
  13. ["source","java",subs="attributes,callouts,macros"]
  14. --------------------------------------------------
  15. include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[delete-index-request-timeout]
  16. --------------------------------------------------
  17. <1> Timeout to wait for the all the nodes to acknowledge the index deletion as a `TimeValue`
  18. <2> Timeout to wait for the all the nodes to acknowledge the index deletion as a `String`
  19. ["source","java",subs="attributes,callouts,macros"]
  20. --------------------------------------------------
  21. include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[delete-index-request-masterTimeout]
  22. --------------------------------------------------
  23. <1> Timeout to connect to the master node as a `TimeValue`
  24. <2> Timeout to connect to the master node as a `String`
  25. ["source","java",subs="attributes,callouts,macros"]
  26. --------------------------------------------------
  27. include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[delete-index-request-indicesOptions]
  28. --------------------------------------------------
  29. <1> Setting `IndicesOptions` controls how unavailable indices are resolved and
  30. how wildcard expressions are expanded
  31. [[java-rest-high-delete-index-sync]]
  32. ==== Synchronous Execution
  33. ["source","java",subs="attributes,callouts,macros"]
  34. --------------------------------------------------
  35. include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[delete-index-execute]
  36. --------------------------------------------------
  37. [[java-rest-high-delete-index-async]]
  38. ==== Asynchronous Execution
  39. The asynchronous execution of a delete index request requires both the `DeleteIndexRequest`
  40. instance and an `ActionListener` instance to be passed to the asynchronous
  41. method:
  42. ["source","java",subs="attributes,callouts,macros"]
  43. --------------------------------------------------
  44. include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[delete-index-execute-async]
  45. --------------------------------------------------
  46. <1> The `DeleteIndexRequest` to execute and the `ActionListener` to use when
  47. the execution completes
  48. The asynchronous method does not block and returns immediately. Once it is
  49. completed the `ActionListener` is called back using the `onResponse` method
  50. if the execution successfully completed or using the `onFailure` method if
  51. it failed.
  52. A typical listener for `DeleteIndexResponse` looks like:
  53. ["source","java",subs="attributes,callouts,macros"]
  54. --------------------------------------------------
  55. include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[delete-index-execute-listener]
  56. --------------------------------------------------
  57. <1> Called when the execution is successfully completed. The response is
  58. provided as an argument
  59. <2> Called in case of failure. The raised exception is provided as an argument
  60. [[java-rest-high-delete-index-response]]
  61. ==== Delete Index Response
  62. The returned `DeleteIndexResponse` allows to retrieve information about the executed
  63. operation as follows:
  64. ["source","java",subs="attributes,callouts,macros"]
  65. --------------------------------------------------
  66. include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[delete-index-response]
  67. --------------------------------------------------
  68. <1> Indicates whether all of the nodes have acknowledged the request
  69. If the index was not found, an `ElasticsearchException` will be thrown:
  70. ["source","java",subs="attributes,callouts,macros"]
  71. --------------------------------------------------
  72. include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[delete-index-notfound]
  73. --------------------------------------------------
  74. <1> Do something if the index to be deleted was not found