mirror of
https://github.com/elastic/elasticsearch.git
synced 2025-04-24 23:27:25 -04:00
Add Get Aliases API to the high-level REST client (#28799)
Given the weirdness of the response returned by the get alias API, we went for a client specific response, which allows us to hold the error message, exception and status returned as part of the response together with aliases. See #30536 . Relates to #27205
This commit is contained in:
parent
a178290b60
commit
7d7ead95b2
17 changed files with 1001 additions and 48 deletions
94
docs/java-rest/high-level/indices/get_alias.asciidoc
Normal file
94
docs/java-rest/high-level/indices/get_alias.asciidoc
Normal file
|
@ -0,0 +1,94 @@
|
|||
[[java-rest-high-get-alias]]
|
||||
=== Get Alias API
|
||||
|
||||
[[java-rest-high-get-alias-request]]
|
||||
==== Get Alias Request
|
||||
|
||||
The Get Alias API uses `GetAliasesRequest` as its request object.
|
||||
One or more aliases can be optionally provided either at construction
|
||||
time or later on through the relevant setter method.
|
||||
|
||||
["source","java",subs="attributes,callouts,macros"]
|
||||
--------------------------------------------------
|
||||
include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[get-alias-request]
|
||||
--------------------------------------------------
|
||||
|
||||
==== Optional arguments
|
||||
The following arguments can optionally be provided:
|
||||
|
||||
["source","java",subs="attributes,callouts,macros"]
|
||||
--------------------------------------------------
|
||||
include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[get-alias-request-alias]
|
||||
--------------------------------------------------
|
||||
<1> One or more aliases to retrieve
|
||||
|
||||
["source","java",subs="attributes,callouts,macros"]
|
||||
--------------------------------------------------
|
||||
include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[get-alias-request-indices]
|
||||
--------------------------------------------------
|
||||
<1> The index or indices that the alias is associated with
|
||||
|
||||
["source","java",subs="attributes,callouts,macros"]
|
||||
--------------------------------------------------
|
||||
include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[get-alias-request-indicesOptions]
|
||||
--------------------------------------------------
|
||||
<1> Setting `IndicesOptions` controls how unavailable indices are resolved and
|
||||
how wildcard expressions are expanded when looking for aliases that belong to
|
||||
specified indices.
|
||||
|
||||
["source","java",subs="attributes,callouts,macros"]
|
||||
--------------------------------------------------
|
||||
include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[get-alias-request-local]
|
||||
--------------------------------------------------
|
||||
<1> The `local` flag (defaults to `false`) controls whether the aliases need
|
||||
to be looked up in the local cluster state or in the cluster state held by
|
||||
the elected master node
|
||||
|
||||
[[java-rest-high-get-alias-sync]]
|
||||
==== Synchronous Execution
|
||||
|
||||
["source","java",subs="attributes,callouts,macros"]
|
||||
--------------------------------------------------
|
||||
include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[get-alias-execute]
|
||||
--------------------------------------------------
|
||||
|
||||
[[java-rest-high-get-alias-async]]
|
||||
==== Asynchronous Execution
|
||||
|
||||
The asynchronous execution of a get alias request requires both a `GetAliasesRequest`
|
||||
instance and an `ActionListener` instance to be passed to the asynchronous
|
||||
method:
|
||||
|
||||
["source","java",subs="attributes,callouts,macros"]
|
||||
--------------------------------------------------
|
||||
include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[get-alias-execute-async]
|
||||
--------------------------------------------------
|
||||
<1> The `GetAliasesRequest` to execute and the `ActionListener` to use when
|
||||
the execution completes
|
||||
|
||||
The asynchronous method does not block and returns immediately. Once it is
|
||||
completed the `ActionListener` is called back using the `onResponse` method
|
||||
if the execution successfully completed or using the `onFailure` method if
|
||||
it failed.
|
||||
|
||||
A typical listener for the `Boolean` response looks like:
|
||||
|
||||
["source","java",subs="attributes,callouts,macros"]
|
||||
--------------------------------------------------
|
||||
include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[get-alias-listener]
|
||||
--------------------------------------------------
|
||||
<1> Called when the execution is successfully completed. The response is
|
||||
provided as an argument
|
||||
<2> Called in case of failure. The raised exception is provided as an argument
|
||||
|
||||
[[java-rest-high-get-alias-response]]
|
||||
==== Get Alias Response
|
||||
|
||||
The returned `GetAliasesResponse` allows to retrieve information about the
|
||||
executed operation as follows:
|
||||
|
||||
["source","java",subs="attributes,callouts,macros"]
|
||||
--------------------------------------------------
|
||||
include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[get-alias-response]
|
||||
--------------------------------------------------
|
||||
<1> Retrieves a map of indices and their aliases
|
|
@ -80,6 +80,7 @@ Mapping Management::
|
|||
Alias Management::
|
||||
* <<java-rest-high-update-aliases>>
|
||||
* <<java-rest-high-exists-alias>>
|
||||
* <<java-rest-high-get-alias>>
|
||||
|
||||
include::indices/create_index.asciidoc[]
|
||||
include::indices/delete_index.asciidoc[]
|
||||
|
@ -98,6 +99,7 @@ include::indices/put_mapping.asciidoc[]
|
|||
include::indices/get_mappings.asciidoc[]
|
||||
include::indices/update_aliases.asciidoc[]
|
||||
include::indices/exists_alias.asciidoc[]
|
||||
include::indices/get_alias.asciidoc[]
|
||||
include::indices/put_settings.asciidoc[]
|
||||
include::indices/get_settings.asciidoc[]
|
||||
include::indices/put_template.asciidoc[]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue