OpenSearch/docs/java-rest/high-level/indices/get_alias.asciidoc

86 lines
3.2 KiB
Plaintext
Raw Normal View History

--
:api: get-alias
:request: GetAliasesRequest
:response: GetAliasesResponse
--
[id="{upid}-{api}"]
=== Get Alias API
[id="{upid}-{api}-request"]
==== Get Alias Request
The Get Alias API uses +{request}+ 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-file}[{api}-request]
--------------------------------------------------
==== Optional arguments
The following arguments can optionally be provided:
["source","java",subs="attributes,callouts,macros"]
--------------------------------------------------
include-tagged::{doc-tests-file}[{api}-request-alias]
--------------------------------------------------
<1> One or more aliases to retrieve
["source","java",subs="attributes,callouts,macros"]
--------------------------------------------------
include-tagged::{doc-tests-file}[{api}-request-indices]
--------------------------------------------------
<1> The index or indices that the alias is associated with
["source","java",subs="attributes,callouts,macros"]
--------------------------------------------------
include-tagged::{doc-tests-file}[{api}-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-file}[{api}-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
include::../execution.asciidoc[]
[id="{upid}-{api}-response"]
==== Get Alias Response
The returned +{response}+ allows to retrieve information about the
executed operation as follows:
["source","java",subs="attributes,callouts,macros"]
--------------------------------------------------
include-tagged::{doc-tests-file}[{api}-response]
--------------------------------------------------
<1> Retrieves a map of indices and their aliases
+{response}+ class contains information about errors if they occurred.
This info could be in fields `error` or `exception` depends on a case.
["source","java",subs="attributes,callouts,macros"]
--------------------------------------------------
include-tagged::{doc-tests-file}[{api}-response-error]
--------------------------------------------------
<1> Client sets status to `NOT_FOUND` if at least one item of specified
indices or aliases is not found. Otherwise it is `OK`.
<2> If at least one item of specified indices isn't exist client sets
`ElasticsearchException` and returns empty result.
<3> If at least one item of specified aliases ins't exist client puts
error description in `error` field and returns partial result if any
of other patterns match.
If user specified indices or aliases as regular expressions
and nothing was found client returns `OK` status and no errors.