open_index.asciidoc 4.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. [[java-rest-high-open-index]]
  2. === Open Index API
  3. [[java-rest-high-open-index-request]]
  4. ==== Open Index Request
  5. An `OpenIndexRequest` requires an `index` argument:
  6. ["source","java",subs="attributes,callouts,macros"]
  7. --------------------------------------------------
  8. include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[open-index-request]
  9. --------------------------------------------------
  10. <1> The index to open
  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[open-index-request-timeout]
  16. --------------------------------------------------
  17. <1> Timeout to wait for the all the nodes to acknowledge the index is opened
  18. as a `TimeValue`
  19. <2> Timeout to wait for the all the nodes to acknowledge the index is opened
  20. as a `String`
  21. ["source","java",subs="attributes,callouts,macros"]
  22. --------------------------------------------------
  23. include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[open-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[open-index-request-waitForActiveShards]
  30. --------------------------------------------------
  31. <1> The number of active shard copies to wait for before the open index API
  32. returns a response, as an `int`
  33. <2> The number of active shard copies to wait for before the open index API
  34. returns a response, as an `ActiveShardCount`
  35. ["source","java",subs="attributes,callouts,macros"]
  36. --------------------------------------------------
  37. include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[open-index-request-indicesOptions]
  38. --------------------------------------------------
  39. <1> Setting `IndicesOptions` controls how unavailable indices are resolved and
  40. how wildcard expressions are expanded
  41. [[java-rest-high-open-index-sync]]
  42. ==== Synchronous Execution
  43. ["source","java",subs="attributes,callouts,macros"]
  44. --------------------------------------------------
  45. include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[open-index-execute]
  46. --------------------------------------------------
  47. [[java-rest-high-open-index-async]]
  48. ==== Asynchronous Execution
  49. The asynchronous execution of an open index request requires both the `OpenIndexRequest`
  50. instance and an `ActionListener` instance to be passed to the asynchronous
  51. method:
  52. ["source","java",subs="attributes,callouts,macros"]
  53. --------------------------------------------------
  54. include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[open-index-execute-async]
  55. --------------------------------------------------
  56. <1> The `OpenIndexRequest` to execute and the `ActionListener` to use when
  57. the execution completes
  58. The asynchronous method does not block and returns immediately. Once it is
  59. completed the `ActionListener` is called back using the `onResponse` method
  60. if the execution successfully completed or using the `onFailure` method if
  61. it failed.
  62. A typical listener for `OpenIndexResponse` looks like:
  63. ["source","java",subs="attributes,callouts,macros"]
  64. --------------------------------------------------
  65. include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[open-index-execute-listener]
  66. --------------------------------------------------
  67. <1> Called when the execution is successfully completed. The response is
  68. provided as an argument
  69. <2> Called in case of failure. The raised exception is provided as an argument
  70. [[java-rest-high-open-index-response]]
  71. ==== Open Index Response
  72. The returned `OpenIndexResponse` allows to retrieve information about the
  73. executed operation as follows:
  74. ["source","java",subs="attributes,callouts,macros"]
  75. --------------------------------------------------
  76. include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[open-index-response]
  77. --------------------------------------------------
  78. <1> Indicates whether all of the nodes have acknowledged the request
  79. <2> Indicates whether the requisite number of shard copies were started for
  80. each shard in the index before timing out