97 lines
4.3 KiB
Plaintext
97 lines
4.3 KiB
Plaintext
[[java-rest-high-update-aliases]]
|
|
=== Update Aliases API
|
|
|
|
[[java-rest-high-update-aliases-request]]
|
|
==== Indices Aliases Request
|
|
|
|
The Update Aliases API allows aliasing an index with a name, with all APIs
|
|
automatically converting the alias name to the actual index name.
|
|
|
|
An `IndicesAliasesRequest` must have at least one `AliasActions`:
|
|
|
|
["source","java",subs="attributes,callouts,macros"]
|
|
--------------------------------------------------
|
|
include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[update-aliases-request]
|
|
--------------------------------------------------
|
|
<1> Creates an `IndicesAliasesRequest`
|
|
<2> Creates an `AliasActions` that aliases index `test1` with `alias1`
|
|
<3> Adds the alias action to the request
|
|
|
|
The following action types are supported: `add` - alias an index, `remove` -
|
|
removes the alias associated with the index, and `remove_index` - deletes the
|
|
index.
|
|
|
|
["source","java",subs="attributes,callouts,macros"]
|
|
--------------------------------------------------
|
|
include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[update-aliases-request2]
|
|
--------------------------------------------------
|
|
<1> Creates an alias `alias1` with an optional filter on field `year`
|
|
<2> Creates an alias `alias2` associated with two indices and with an optional routing
|
|
<3> Removes the associated alias `alias3`
|
|
<4> `remove_index` is just like <<java-rest-high-delete-index>>
|
|
|
|
==== Optional arguments
|
|
The following arguments can optionally be provided:
|
|
|
|
["source","java",subs="attributes,callouts,macros"]
|
|
--------------------------------------------------
|
|
include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[update-aliases-request-timeout]
|
|
--------------------------------------------------
|
|
<1> Timeout to wait for the all the nodes to acknowledge the operation as a `TimeValue`
|
|
<2> Timeout to wait for the all the nodes to acknowledge the operation as a `String`
|
|
|
|
["source","java",subs="attributes,callouts,macros"]
|
|
--------------------------------------------------
|
|
include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[update-aliases-request-masterTimeout]
|
|
--------------------------------------------------
|
|
<1> Timeout to connect to the master node as a `TimeValue`
|
|
<2> Timeout to connect to the master node as a `String`
|
|
|
|
[[java-rest-high-update-aliases-sync]]
|
|
==== Synchronous Execution
|
|
|
|
["source","java",subs="attributes,callouts,macros"]
|
|
--------------------------------------------------
|
|
include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[update-aliases-execute]
|
|
--------------------------------------------------
|
|
|
|
[[java-rest-high-update-aliases-async]]
|
|
==== Asynchronous Execution
|
|
|
|
The asynchronous execution of an update index aliases request requires both the `IndicesAliasesRequest`
|
|
instance and an `ActionListener` instance to be passed to the asynchronous
|
|
method:
|
|
|
|
["source","java",subs="attributes,callouts,macros"]
|
|
--------------------------------------------------
|
|
include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[update-aliases-execute-async]
|
|
--------------------------------------------------
|
|
<1> The `IndicesAliasesRequest` 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 `IndicesAliasesResponse` looks like:
|
|
|
|
["source","java",subs="attributes,callouts,macros"]
|
|
--------------------------------------------------
|
|
include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[update-aliases-execute-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-update-aliases-response]]
|
|
==== Indices Aliases Response
|
|
|
|
The returned `IndicesAliasesResponse` allows to retrieve information about the
|
|
executed operation as follows:
|
|
|
|
["source","java",subs="attributes,callouts,macros"]
|
|
--------------------------------------------------
|
|
include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[update-aliases-response]
|
|
--------------------------------------------------
|
|
<1> Indicates whether all of the nodes have acknowledged the request |