-
Notifications
You must be signed in to change notification settings - Fork 24.8k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[DOCS] Add get index alias API docs (#46046)
- Loading branch information
Showing
5 changed files
with
194 additions
and
119 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters