get_alias.asciidoc 4.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. [[java-rest-high-get-alias]]
  2. === Get Alias API
  3. [[java-rest-high-get-alias-request]]
  4. ==== Get Alias Request
  5. The Get Alias API uses `GetAliasesRequest` as its request object.
  6. One or more aliases can be optionally provided either at construction
  7. time or later on through the relevant setter method.
  8. ["source","java",subs="attributes,callouts,macros"]
  9. --------------------------------------------------
  10. include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[get-alias-request]
  11. --------------------------------------------------
  12. ==== Optional arguments
  13. The following arguments can optionally be provided:
  14. ["source","java",subs="attributes,callouts,macros"]
  15. --------------------------------------------------
  16. include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[get-alias-request-alias]
  17. --------------------------------------------------
  18. <1> One or more aliases to retrieve
  19. ["source","java",subs="attributes,callouts,macros"]
  20. --------------------------------------------------
  21. include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[get-alias-request-indices]
  22. --------------------------------------------------
  23. <1> The index or indices that the alias is associated with
  24. ["source","java",subs="attributes,callouts,macros"]
  25. --------------------------------------------------
  26. include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[get-alias-request-indicesOptions]
  27. --------------------------------------------------
  28. <1> Setting `IndicesOptions` controls how unavailable indices are resolved and
  29. how wildcard expressions are expanded when looking for aliases that belong to
  30. specified indices.
  31. ["source","java",subs="attributes,callouts,macros"]
  32. --------------------------------------------------
  33. include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[get-alias-request-local]
  34. --------------------------------------------------
  35. <1> The `local` flag (defaults to `false`) controls whether the aliases need
  36. to be looked up in the local cluster state or in the cluster state held by
  37. the elected master node
  38. [[java-rest-high-get-alias-sync]]
  39. ==== Synchronous Execution
  40. ["source","java",subs="attributes,callouts,macros"]
  41. --------------------------------------------------
  42. include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[get-alias-execute]
  43. --------------------------------------------------
  44. [[java-rest-high-get-alias-async]]
  45. ==== Asynchronous Execution
  46. The asynchronous execution of a get alias request requires both a `GetAliasesRequest`
  47. instance and an `ActionListener` instance to be passed to the asynchronous
  48. method:
  49. ["source","java",subs="attributes,callouts,macros"]
  50. --------------------------------------------------
  51. include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[get-alias-execute-async]
  52. --------------------------------------------------
  53. <1> The `GetAliasesRequest` to execute and the `ActionListener` to use when
  54. the execution completes
  55. The asynchronous method does not block and returns immediately. Once it is
  56. completed the `ActionListener` is called back using the `onResponse` method
  57. if the execution successfully completed or using the `onFailure` method if
  58. it failed.
  59. A typical listener for the `Boolean` response looks like:
  60. ["source","java",subs="attributes,callouts,macros"]
  61. --------------------------------------------------
  62. include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[get-alias-listener]
  63. --------------------------------------------------
  64. <1> Called when the execution is successfully completed. The response is
  65. provided as an argument
  66. <2> Called in case of failure. The raised exception is provided as an argument
  67. [[java-rest-high-get-alias-response]]
  68. ==== Get Alias Response
  69. The returned `GetAliasesResponse` allows to retrieve information about the
  70. executed operation as follows:
  71. ["source","java",subs="attributes,callouts,macros"]
  72. --------------------------------------------------
  73. include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[get-alias-response]
  74. --------------------------------------------------
  75. <1> Retrieves a map of indices and their aliases