close_index.asciidoc 3.7 KB

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