[[java-rest-high-exists-alias]] === Exists Alias API [[java-rest-high-exists-alias-request]] ==== Exists Alias Request The Exists 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[exists-alias-request] -------------------------------------------------- ==== Optional arguments The following arguments can optionally be provided: ["source","java",subs="attributes,callouts,macros"] -------------------------------------------------- include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[exists-alias-request-alias] -------------------------------------------------- <1> One or more aliases to look for ["source","java",subs="attributes,callouts,macros"] -------------------------------------------------- include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[exists-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[exists-alias-request-indicesOptions] -------------------------------------------------- <1> Setting `IndicesOptions` controls how unavailable indices are resolved and how wildcard expressions are expanded ["source","java",subs="attributes,callouts,macros"] -------------------------------------------------- include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[exists-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-exists-alias-sync]] ==== Synchronous Execution ["source","java",subs="attributes,callouts,macros"] -------------------------------------------------- include-tagged::{doc-tests}/IndicesClientDocumentationIT.java[exists-alias-execute] -------------------------------------------------- [[java-rest-high-exists-alias-async]] ==== Asynchronous Execution The asynchronous execution of a exists 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[exists-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[exists-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-exists-alias-response]] ==== Exists Alias Response The Exists Alias API returns a `boolean` that indicates whether the provided alias (or aliases) was found or not.