update_aliases.asciidoc 4.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697
  1. [[java-rest-high-update-aliases]]
  2. === Index Aliases API
  3. [[java-rest-high-update-aliases-request]]
  4. ==== Indices Aliases Request
  5. The Index Aliases API allows aliasing an index with a name, with all APIs
  6. automatically converting the alias name to the actual index name.
  7. An `IndicesAliasesRequest` must have at least one `AliasActions`:
  8. ["source","java",subs="attributes,callouts,macros"]
  9. --------------------------------------------------
  10. include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[update-aliases-request]
  11. --------------------------------------------------
  12. <1> Creates an `IndicesAliasesRequest`
  13. <2> Creates an `AliasActions` that aliases index `test1` with `alias1`
  14. <3> Adds the alias action to the request
  15. The following action types are supported: `add` - alias an index, `remove` -
  16. removes the alias associated with the index, and `remove_index` - deletes the
  17. index.
  18. ["source","java",subs="attributes,callouts,macros"]
  19. --------------------------------------------------
  20. include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[update-aliases-request2]
  21. --------------------------------------------------
  22. <1> Creates an alias `alias1` with an optional filter on field `year`
  23. <2> Creates an alias `alias2` associated with two indices and with an optional routing
  24. <3> Removes the associated alias `alias3`
  25. <4> `remove_index` is just like <<java-rest-high-delete-index>>
  26. ==== Optional arguments
  27. The following arguments can optionally be provided:
  28. ["source","java",subs="attributes,callouts,macros"]
  29. --------------------------------------------------
  30. include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[update-aliases-request-timeout]
  31. --------------------------------------------------
  32. <1> Timeout to wait for the all the nodes to acknowledge the operation as a `TimeValue`
  33. <2> Timeout to wait for the all the nodes to acknowledge the operation as a `String`
  34. ["source","java",subs="attributes,callouts,macros"]
  35. --------------------------------------------------
  36. include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[update-aliases-request-masterTimeout]
  37. --------------------------------------------------
  38. <1> Timeout to connect to the master node as a `TimeValue`
  39. <2> Timeout to connect to the master node as a `String`
  40. [[java-rest-high-update-aliases-sync]]
  41. ==== Synchronous Execution
  42. ["source","java",subs="attributes,callouts,macros"]
  43. --------------------------------------------------
  44. include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[update-aliases-execute]
  45. --------------------------------------------------
  46. [[java-rest-high-update-aliases-async]]
  47. ==== Asynchronous Execution
  48. The asynchronous execution of an update index aliases request requires both the `IndicesAliasesRequest`
  49. instance and an `ActionListener` instance to be passed to the asynchronous
  50. method:
  51. ["source","java",subs="attributes,callouts,macros"]
  52. --------------------------------------------------
  53. include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[update-aliases-execute-async]
  54. --------------------------------------------------
  55. <1> The `IndicesAliasesRequest` to execute and the `ActionListener` to use when
  56. the execution completes
  57. The asynchronous method does not block and returns immediately. Once it is
  58. completed the `ActionListener` is called back using the `onResponse` method
  59. if the execution successfully completed or using the `onFailure` method if
  60. it failed.
  61. A typical listener for `IndicesAliasesResponse` looks like:
  62. ["source","java",subs="attributes,callouts,macros"]
  63. --------------------------------------------------
  64. include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[update-aliases-execute-listener]
  65. --------------------------------------------------
  66. <1> Called when the execution is successfully completed. The response is
  67. provided as an argument
  68. <2> Called in case of failure. The raised exception is provided as an argument
  69. [[java-rest-high-update-aliases-response]]
  70. ==== Indices Aliases Response
  71. The returned `IndicesAliasesResponse` allows to retrieve information about the
  72. executed operation as follows:
  73. ["source","java",subs="attributes,callouts,macros"]
  74. --------------------------------------------------
  75. include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[update-aliases-response]
  76. --------------------------------------------------
  77. <1> Indicates whether all of the nodes have acknowledged the request