2019-08-29 09:44:58 -04:00
|
|
|
[[indices-get-alias]]
|
|
|
|
=== Get index alias API
|
|
|
|
++++
|
|
|
|
<titleabbrev>Get index alias</titleabbrev>
|
|
|
|
++++
|
|
|
|
|
|
|
|
Returns information about one or more index aliases.
|
|
|
|
|
2020-06-01 19:42:53 -04:00
|
|
|
include::{es-repo-dir}/glossary.asciidoc[tag=index-alias-desc]
|
2019-08-29 09:44:58 -04:00
|
|
|
|
2019-09-06 11:31:13 -04:00
|
|
|
[source,console]
|
2019-08-29 09:44:58 -04:00
|
|
|
----
|
|
|
|
GET /twitter/_alias/alias1
|
|
|
|
----
|
|
|
|
// TEST[setup:twitter]
|
|
|
|
// TEST[s/^/PUT twitter\/_alias\/alias1\n/]
|
|
|
|
|
|
|
|
|
|
|
|
[[get-alias-api-request]]
|
|
|
|
==== {api-request-title}
|
|
|
|
|
|
|
|
`GET /_alias`
|
|
|
|
|
|
|
|
`GET /_alias/<alias>`
|
|
|
|
|
|
|
|
`GET /<index>/_alias/<alias>`
|
|
|
|
|
|
|
|
|
|
|
|
[[get-alias-api-path-params]]
|
|
|
|
==== {api-path-parms-title}
|
|
|
|
|
|
|
|
`<alias>`::
|
|
|
|
(Optional, string)
|
2020-06-01 19:42:53 -04:00
|
|
|
include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=index-alias]
|
2019-08-29 09:44:58 -04:00
|
|
|
+
|
|
|
|
To retrieve information for all index aliases,
|
|
|
|
use a value of `_all` or `*`.
|
|
|
|
|
2020-06-01 19:42:53 -04:00
|
|
|
include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=index]
|
2019-08-29 09:44:58 -04:00
|
|
|
|
|
|
|
|
|
|
|
[[get-alias-api-query-params]]
|
|
|
|
==== {api-query-parms-title}
|
|
|
|
|
2020-06-01 19:42:53 -04:00
|
|
|
include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=allow-no-indices]
|
2020-02-24 05:57:32 -05:00
|
|
|
+
|
|
|
|
Defaults to `true`.
|
2019-08-29 09:44:58 -04:00
|
|
|
|
2020-06-01 19:42:53 -04:00
|
|
|
include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=expand-wildcards]
|
2019-08-29 09:44:58 -04:00
|
|
|
+
|
|
|
|
Defaults to `all`.
|
|
|
|
|
2020-06-01 19:42:53 -04:00
|
|
|
include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=index-ignore-unavailable]
|
2019-08-29 09:44:58 -04:00
|
|
|
|
2020-06-01 19:42:53 -04:00
|
|
|
include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=local]
|
2019-08-29 09:44:58 -04:00
|
|
|
|
|
|
|
|
|
|
|
[[get-alias-api-example]]
|
|
|
|
==== {api-examples-title}
|
|
|
|
|
|
|
|
[[get-alias-api-all-ex]]
|
|
|
|
===== Get all aliases for an index
|
|
|
|
|
|
|
|
You can add index aliases during index creation
|
|
|
|
using a <<indices-create-index,create index API>> request.
|
|
|
|
|
|
|
|
The following create index API request creates the `logs_20302801` index
|
|
|
|
with two aliases:
|
|
|
|
|
|
|
|
* `current_day`
|
|
|
|
* `2030`, which only returns documents
|
|
|
|
in the `logs_20302801` index
|
|
|
|
with a `year` field value of `2030`
|
|
|
|
|
2019-09-06 11:31:13 -04:00
|
|
|
[source,console]
|
2019-08-29 09:44:58 -04:00
|
|
|
--------------------------------------------------
|
|
|
|
PUT /logs_20302801
|
|
|
|
{
|
|
|
|
"aliases" : {
|
|
|
|
"current_day" : {},
|
|
|
|
"2030" : {
|
|
|
|
"filter" : {
|
|
|
|
"term" : {"year" : 2030 }
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
--------------------------------------------------
|
|
|
|
|
|
|
|
The following get index alias API request returns all aliases
|
|
|
|
for the index `logs_20302801`:
|
|
|
|
|
2019-09-06 11:31:13 -04:00
|
|
|
[source,console]
|
2019-08-29 09:44:58 -04:00
|
|
|
--------------------------------------------------
|
|
|
|
GET /logs_20302801/_alias/*
|
|
|
|
--------------------------------------------------
|
|
|
|
// TEST[continued]
|
|
|
|
|
|
|
|
The API returns the following response:
|
|
|
|
|
2019-09-06 09:22:08 -04:00
|
|
|
[source,console-result]
|
2019-08-29 09:44:58 -04:00
|
|
|
--------------------------------------------------
|
|
|
|
{
|
|
|
|
"logs_20302801" : {
|
|
|
|
"aliases" : {
|
|
|
|
"current_day" : {
|
|
|
|
},
|
|
|
|
"2030" : {
|
|
|
|
"filter" : {
|
|
|
|
"term" : {
|
|
|
|
"year" : 2030
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
--------------------------------------------------
|
|
|
|
|
|
|
|
|
|
|
|
[[get-alias-api-named-ex]]
|
|
|
|
===== Get a specific alias
|
|
|
|
|
|
|
|
The following index alias API request returns the `2030` alias:
|
|
|
|
|
2019-09-06 11:31:13 -04:00
|
|
|
[source,console]
|
2019-08-29 09:44:58 -04:00
|
|
|
--------------------------------------------------
|
|
|
|
GET /_alias/2030
|
|
|
|
--------------------------------------------------
|
|
|
|
// TEST[continued]
|
|
|
|
|
|
|
|
The API returns the following response:
|
|
|
|
|
2019-09-06 09:22:08 -04:00
|
|
|
[source,console-result]
|
2019-08-29 09:44:58 -04:00
|
|
|
--------------------------------------------------
|
|
|
|
{
|
|
|
|
"logs_20302801" : {
|
|
|
|
"aliases" : {
|
|
|
|
"2030" : {
|
|
|
|
"filter" : {
|
|
|
|
"term" : {
|
|
|
|
"year" : 2030
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
--------------------------------------------------
|
2019-09-06 09:22:08 -04:00
|
|
|
|
2019-08-29 09:44:58 -04:00
|
|
|
|
|
|
|
[[get-alias-api-wildcard-ex]]
|
|
|
|
===== Get aliases based on a wildcard
|
|
|
|
|
|
|
|
The following index alias API request returns any alias that begin with `20`:
|
|
|
|
|
2019-09-06 11:31:13 -04:00
|
|
|
[source,console]
|
2019-08-29 09:44:58 -04:00
|
|
|
--------------------------------------------------
|
|
|
|
GET /_alias/20*
|
|
|
|
--------------------------------------------------
|
|
|
|
// TEST[continued]
|
|
|
|
|
|
|
|
The API returns the following response:
|
|
|
|
|
2019-09-06 09:22:08 -04:00
|
|
|
[source,console-result]
|
2019-08-29 09:44:58 -04:00
|
|
|
--------------------------------------------------
|
|
|
|
{
|
|
|
|
"logs_20302801" : {
|
|
|
|
"aliases" : {
|
|
|
|
"2030" : {
|
|
|
|
"filter" : {
|
|
|
|
"term" : {
|
|
|
|
"year" : 2030
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
--------------------------------------------------
|