-
Notifications
You must be signed in to change notification settings - Fork 24.9k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[DOCS] Separate add index alias API docs (#46086)
- Loading branch information
Showing
4 changed files
with
167 additions
and
129 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
[[indices-add-alias]] | ||
=== Add index alias API | ||
++++ | ||
<titleabbrev>Add index alias</titleabbrev> | ||
++++ | ||
|
||
Creates or updates an index alias. | ||
|
||
include::alias-exists.asciidoc[tag=index-alias-def] | ||
|
||
[source,js] | ||
---- | ||
PUT /twitter/_alias/alias1 | ||
---- | ||
// CONSOLE | ||
// TEST[setup:twitter] | ||
|
||
|
||
[[add-alias-api-request]] | ||
==== {api-request-title} | ||
|
||
`PUT /<index>/_alias/<alias>` | ||
|
||
`POST /<index>/_alias/<alias>` | ||
|
||
`PUT /<index>/_aliases/<alias>` | ||
|
||
`POST /<index>/_aliases/<alias>` | ||
|
||
|
||
[[add-alias-api-path-params]] | ||
==== {api-path-parms-title} | ||
|
||
`<index>`:: | ||
(Required, string) | ||
Comma-separated list or wildcard expression of index names | ||
to add to the alias. | ||
+ | ||
To add all indices in the cluster to the alias, | ||
use a value of `_all`. | ||
|
||
`<alias>`:: | ||
(Required, string) | ||
Name of the index alias to create or update. | ||
|
||
|
||
[[add-alias-api-query-params]] | ||
==== {api-query-parms-title} | ||
|
||
include::{docdir}/rest-api/common-parms.asciidoc[tag=timeoutparms] | ||
|
||
|
||
[[add-alias-api-request-body]] | ||
==== {api-request-body-title} | ||
|
||
`filter`:: | ||
(Required, query object) | ||
include::{docdir}/rest-api/common-parms.asciidoc[tag=index-alias-filter] | ||
|
||
include::{docdir}/rest-api/common-parms.asciidoc[tag=index-routing] | ||
|
||
[[add-alias-api-example]] | ||
==== {api-examples-title} | ||
|
||
[[alias-adding]] | ||
===== Add a time-based alias | ||
|
||
The following request creates an alias, `2030`, | ||
for the `logs_20302801` index. | ||
|
||
[source,js] | ||
-------------------------------------------------- | ||
PUT /logs_20302801/_alias/2030 | ||
-------------------------------------------------- | ||
// CONSOLE | ||
// TEST[s/^/PUT logs_20302801\n/] | ||
|
||
[[add-alias-api-user-ex]] | ||
===== Add a user-based alias | ||
|
||
First, create an index, `users`, | ||
with a mapping for the `user_id` field: | ||
|
||
[source,js] | ||
-------------------------------------------------- | ||
PUT /users | ||
{ | ||
"mappings" : { | ||
"properties" : { | ||
"user_id" : {"type" : "integer"} | ||
} | ||
} | ||
} | ||
-------------------------------------------------- | ||
// CONSOLE | ||
|
||
Then add the index alias for a specific user, `user_12`: | ||
|
||
[source,js] | ||
-------------------------------------------------- | ||
PUT /users/_alias/user_12 | ||
{ | ||
"routing" : "12", | ||
"filter" : { | ||
"term" : { | ||
"user_id" : 12 | ||
} | ||
} | ||
} | ||
-------------------------------------------------- | ||
// CONSOLE | ||
// TEST[continued] | ||
|
||
[[alias-index-creation]] | ||
===== Add an alias during index creation | ||
|
||
You can use the <<create-index-aliases,create index API>> | ||
to add an index alias during index creation. | ||
|
||
[source,js] | ||
-------------------------------------------------- | ||
PUT /logs_20302801 | ||
{ | ||
"mappings" : { | ||
"properties" : { | ||
"year" : {"type" : "integer"} | ||
} | ||
}, | ||
"aliases" : { | ||
"current_day" : {}, | ||
"2030" : { | ||
"filter" : { | ||
"term" : {"year" : 2030 } | ||
} | ||
} | ||
} | ||
} | ||
-------------------------------------------------- | ||
// CONSOLE |
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