Skip to content

Commit

Permalink
[DOCS] Add get index alias API docs (elastic#46046)
Browse files Browse the repository at this point in the history
  • Loading branch information
jrodewig authored and jkakavas committed Sep 2, 2019
1 parent 6c5c41e commit 46819ab
Show file tree
Hide file tree
Showing 5 changed files with 194 additions and 119 deletions.
3 changes: 3 additions & 0 deletions docs/reference/indices.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@ index settings, aliases, mappings, and index templates.
[float]
[[alias-management]]
=== Alias management:
* <<indices-get-alias>>
* <<indices-alias-exists>>
* <<indices-aliases>>

Expand Down Expand Up @@ -93,6 +94,8 @@ include::indices/get-field-mapping.asciidoc[]

include::indices/types-exists.asciidoc[]

include::indices/get-alias.asciidoc[]

include::indices/alias-exists.asciidoc[]

include::indices/aliases.asciidoc[]
Expand Down
3 changes: 1 addition & 2 deletions docs/reference/indices/alias-exists.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -37,8 +37,7 @@ HEAD /_alias/alias1

`<alias>`::
(Required, string)
Comma-separated list or wildcard expression of index alias names
used to limit the request.
include::{docdir}/rest-api/common-parms.asciidoc[tag=index-alias]

include::{docdir}/rest-api/common-parms.asciidoc[tag=index]

Expand Down
117 changes: 0 additions & 117 deletions docs/reference/indices/aliases.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -458,120 +458,3 @@ DELETE /logs_20162801/_alias/current_day
--------------------------------------------------
// CONSOLE
// TEST[continued]

[float]
[[alias-retrieving]]
==== Retrieving existing aliases

The get index alias API allows to filter by
alias name and index name. This api redirects to the master and fetches
the requested index aliases, if available. This api only serialises the
found index aliases.

Possible options:
[horizontal]
`index`::
The index name to get aliases for. Partial names are
supported via wildcards, also multiple index names can be specified
separated with a comma. Also the alias name for an index can be used.

`alias`::
The name of alias to return in the response. Like the index
option, this option supports wildcards and the option the specify
multiple alias names separated by a comma.

`ignore_unavailable`::
What to do if an specified index name doesn't
exist. If set to `true` then those indices are ignored.

The rest endpoint is: `/{index}/_alias/{alias}`.

[float]
===== Examples:

All aliases for the index `logs_20162801`:

[source,js]
--------------------------------------------------
GET /logs_20162801/_alias/*
--------------------------------------------------
// CONSOLE
// TEST[continued]

Response:

[source,js]
--------------------------------------------------
{
"logs_20162801" : {
"aliases" : {
"2016" : {
"filter" : {
"term" : {
"year" : 2016
}
}
}
}
}
}
--------------------------------------------------
// TESTRESPONSE

All aliases with the name 2016 in any index:

[source,js]
--------------------------------------------------
GET /_alias/2016
--------------------------------------------------
// CONSOLE
// TEST[continued]

Response:

[source,js]
--------------------------------------------------
{
"logs_20162801" : {
"aliases" : {
"2016" : {
"filter" : {
"term" : {
"year" : 2016
}
}
}
}
}
}
--------------------------------------------------
// TESTRESPONSE

All aliases that start with 20 in any index:

[source,js]
--------------------------------------------------
GET /_alias/20*
--------------------------------------------------
// CONSOLE
// TEST[continued]

Response:

[source,js]
--------------------------------------------------
{
"logs_20162801" : {
"aliases" : {
"2016" : {
"filter" : {
"term" : {
"year" : 2016
}
}
}
}
}
}
--------------------------------------------------
// TESTRESPONSE
185 changes: 185 additions & 0 deletions docs/reference/indices/get-alias.asciidoc
Original file line number Diff line number Diff line change
@@ -0,0 +1,185 @@
[[indices-get-alias]]
=== Get index alias API
++++
<titleabbrev>Get index alias</titleabbrev>
++++

Returns information about one or more index aliases.

include::alias-exists.asciidoc[tag=index-alias-def]

[source,js]
----
GET /twitter/_alias/alias1
----
// CONSOLE
// 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)
include::{docdir}/rest-api/common-parms.asciidoc[tag=index-alias]
+
To retrieve information for all index aliases,
use a value of `_all` or `*`.

include::{docdir}/rest-api/common-parms.asciidoc[tag=index]


[[get-alias-api-query-params]]
==== {api-query-parms-title}

include::{docdir}/rest-api/common-parms.asciidoc[tag=allow-no-indices]

include::{docdir}/rest-api/common-parms.asciidoc[tag=expand-wildcards]
+
Defaults to `all`.

include::{docdir}/rest-api/common-parms.asciidoc[tag=index-ignore-unavailable]

include::{docdir}/rest-api/common-parms.asciidoc[tag=local]


[[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`

[source,js]
--------------------------------------------------
PUT /logs_20302801
{
"aliases" : {
"current_day" : {},
"2030" : {
"filter" : {
"term" : {"year" : 2030 }
}
}
}
}
--------------------------------------------------
// CONSOLE

The following get index alias API request returns all aliases
for the index `logs_20302801`:

[source,js]
--------------------------------------------------
GET /logs_20302801/_alias/*
--------------------------------------------------
// CONSOLE
// TEST[continued]

The API returns the following response:

[source,js]
--------------------------------------------------
{
"logs_20302801" : {
"aliases" : {
"current_day" : {
},
"2030" : {
"filter" : {
"term" : {
"year" : 2030
}
}
}
}
}
}
--------------------------------------------------
// TESTRESPONSE


[[get-alias-api-named-ex]]
===== Get a specific alias

The following index alias API request returns the `2030` alias:

[source,js]
--------------------------------------------------
GET /_alias/2030
--------------------------------------------------
// CONSOLE
// TEST[continued]

The API returns the following response:

[source,js]
--------------------------------------------------
{
"logs_20302801" : {
"aliases" : {
"2030" : {
"filter" : {
"term" : {
"year" : 2030
}
}
}
}
}
}
--------------------------------------------------
// TESTRESPONSE

[[get-alias-api-wildcard-ex]]
===== Get aliases based on a wildcard

The following index alias API request returns any alias that begin with `20`:

[source,js]
--------------------------------------------------
GET /_alias/20*
--------------------------------------------------
// CONSOLE
// TEST[continued]

The API returns the following response:

[source,js]
--------------------------------------------------
{
"logs_20302801" : {
"aliases" : {
"2030" : {
"filter" : {
"term" : {
"year" : 2030
}
}
}
}
}
}
--------------------------------------------------
// TESTRESPONSE
5 changes: 5 additions & 0 deletions docs/reference/rest-api/common-parms.asciidoc
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@

tag::index-alias[]
Comma-separated list or wildcard expression of index alias names
used to limit the request.
end::index-alias[]

tag::allow-no-indices[]
`allow_no_indices`::
(Optional, boolean) If `true`, the request returns an error if a wildcard
Expand Down

0 comments on commit 46819ab

Please sign in to comment.