Skip to content

Commit 74bc81c

Browse files
authored
[DOCS] Update alias API docs for data stream aliases (#73419)
Updates the docs for several alias APIs for data stream aliases. Also removes some redundant examples now covered in the [aliases guide][0]. [0]: https://www.elastic.co/guide/en/elasticsearch/reference/master/alias.html
1 parent dce50a4 commit 74bc81c

File tree

7 files changed

+164
-438
lines changed

7 files changed

+164
-438
lines changed

docs/reference/alias.asciidoc

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,8 @@ POST _aliases
4545
----
4646
// TEST[s/^/PUT _data_stream\/logs-nginx.access-prod\n/]
4747

48-
The API's `index` and `indices` parameters support wildcards (`*`). If a
49-
wildcard pattern matches both data streams and indices, the action only uses
50-
matching data streams.
48+
The API's `index` and `indices` parameters support wildcards (`*`). Wildcard
49+
patterns that match both data streams and indices return an error.
5150

5251
[source,console]
5352
----

docs/reference/indices/add-alias.asciidoc

Lines changed: 16 additions & 127 deletions
Original file line numberDiff line numberDiff line change
@@ -8,158 +8,47 @@ Adds a data stream or index to an <<alias,alias>>.
88

99
[source,console]
1010
----
11-
PUT /my-index-000001/_alias/alias1
11+
PUT my-data-stream/_alias/my-alias
1212
----
13-
// TEST[setup:my_index]
14-
13+
// TEST[setup:my_data_stream]
14+
// TEST[teardown:data_stream_cleanup]
1515

1616
[[add-alias-api-request]]
1717
==== {api-request-title}
1818

19-
`PUT /<index>/_alias/<alias>`
19+
`POST <target>/_alias/<alias>`
2020

21-
`POST /<index>/_alias/<alias>`
21+
`POST <target>/_aliases/<alias>`
2222

23-
`PUT /<index>/_aliases/<alias>`
23+
`PUT <target>/_alias/<alias>`
2424

25-
`POST /<index>/_aliases/<alias>`
25+
`PUT <target>/_aliases/<alias>`
2626

2727
[[add-alias-api-prereqs]]
2828
==== {api-prereq-title}
2929

3030
* If the {es} {security-features} are enabled, you must have the `manage`
31-
<<privileges-list-indices,index privilege>> for both the index and index alias.
31+
<<privileges-list-indices,index privilege>> for the alias and its data streams
32+
or indices.
3233

3334
[[add-alias-api-path-params]]
3435
==== {api-path-parms-title}
3536

36-
`<index>`::
37-
(Required, string)
38-
Comma-separated list or wildcard expression of index names
39-
to add to the alias.
40-
+
41-
To add all indices in the cluster to the alias,
42-
use a value of `_all`.
43-
+
44-
NOTE: You cannot add <<data-streams,data streams>> to an index alias.
45-
4637
`<alias>`::
47-
(Required, string)
48-
Name of the index alias to create or update. Supports
49-
<<date-math-index-names,date math>>.
38+
(Required, string) Alias to update. If the alias doesn't exist, the request
39+
creates it. Index alias names support <<date-math-index-names,date math>>.
5040

41+
`<target>`::
42+
(Required, string) Comma-separated list of data streams or indices to add.
43+
Supports wildcards (`*`). Wildcard patterns that match both data streams and
44+
indices return an error.
5145

5246
[[add-alias-api-query-params]]
5347
==== {api-query-parms-title}
5448

5549
include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=timeoutparms]
5650

57-
5851
[[add-alias-api-request-body]]
5952
==== {api-request-body-title}
6053

61-
`filter`::
62-
(Optional, query object)
63-
include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=index-alias-filter]
64-
65-
include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=routing]
66-
67-
[[add-alias-api-example]]
68-
==== {api-examples-title}
69-
70-
[[alias-date-math-support]]
71-
===== Date math support
72-
73-
Index alias names support <<date-math-index-names,date math>>.
74-
75-
[source,console]
76-
----
77-
# POST /logs/_alias/<logs_{now/M}>
78-
POST /logs/_alias/%3Clogs_%7Bnow%2FM%7D%3E
79-
----
80-
// TEST[s/^/PUT logs\n/]
81-
82-
[[alias-adding]]
83-
===== Add a time-based alias
84-
85-
The following request creates an alias, `2030`,
86-
for the `logs_20302801` index.
87-
88-
[source,console]
89-
--------------------------------------------------
90-
PUT /logs_20302801/_alias/2030
91-
--------------------------------------------------
92-
// TEST[s/^/PUT logs_20302801\n/]
93-
94-
[[add-alias-api-user-ex]]
95-
===== Add a user-based alias
96-
97-
First, create an index, `users`,
98-
with a mapping for the `user_id` field:
99-
100-
[source,console]
101-
--------------------------------------------------
102-
PUT /users
103-
{
104-
"mappings" : {
105-
"properties" : {
106-
"user_id" : {"type" : "integer"}
107-
}
108-
}
109-
}
110-
--------------------------------------------------
111-
112-
Then add the index alias for a specific user, `user_12`:
113-
114-
[source,console]
115-
--------------------------------------------------
116-
PUT /users/_alias/user_12
117-
{
118-
"routing" : "12",
119-
"filter" : {
120-
"term" : {
121-
"user_id" : 12
122-
}
123-
}
124-
}
125-
--------------------------------------------------
126-
// TEST[continued]
127-
128-
[[alias-index-creation]]
129-
===== Add an alias during index creation
130-
131-
You can use the <<create-index-aliases,create index API>>
132-
to add an index alias during index creation.
133-
134-
[source,console]
135-
--------------------------------------------------
136-
PUT /logs_20302801
137-
{
138-
"mappings": {
139-
"properties": {
140-
"year": { "type": "integer" }
141-
}
142-
},
143-
"aliases": {
144-
"current_day": {},
145-
"2030": {
146-
"filter": {
147-
"term": { "year": 2030 }
148-
}
149-
}
150-
}
151-
}
152-
--------------------------------------------------
153-
154-
The create index API also supports <<date-math-index-names,date math>> in index
155-
alias names.
156-
157-
[source,console]
158-
----
159-
PUT /logs
160-
{
161-
"aliases": {
162-
"<logs_{now/M}>": {}
163-
}
164-
}
165-
----
54+
include::aliases.asciidoc[tag=alias-options]

docs/reference/indices/alias-exists.asciidoc

Lines changed: 20 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -8,35 +8,38 @@ Checks if an <<alias,alias>> exists.
88

99
[source,console]
1010
----
11-
HEAD /_alias/alias1
11+
HEAD _alias/my-alias
1212
----
13-
// TEST[setup:my_index]
14-
// TEST[s/^/PUT my-index-000001\/_alias\/alias1\n/]
15-
13+
// TEST[setup:my_data_stream]
14+
// TEST[s/^/PUT my-data-stream\/_alias\/my-alias\n/]
15+
// TEST[teardown:data_stream_cleanup]
1616

1717
[[alias-exists-api-request]]
1818
==== {api-request-title}
1919

20-
`HEAD /_alias/<alias>`
20+
`HEAD _alias/<alias>`
2121

22-
`HEAD /<index>/_alias/<alias>`
22+
`HEAD <target>/_alias/<alias>`
2323

2424
[[alias-exists-api-prereqs]]
2525
==== {api-prereq-title}
2626

2727
* If the {es} {security-features} are enabled, you must have the
2828
`view_index_metadata` or `manage` <<privileges-list-indices,index privilege>>
29-
for the index alias. If you specify an index, you must also have
30-
`view_index_metadata` or `manage` index privilege for the index.
29+
for the alias. If you specify a target, you must also have the
30+
`view_index_metadata` or `manage` index privilege for the target.
3131

3232
[[alias-exists-api-path-params]]
3333
==== {api-path-parms-title}
3434

3535
`<alias>`::
36-
(Required, string)
37-
include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=index-alias]
36+
(Optional, string) Comma-separated list of aliases to check. Supports wildcards
37+
(`*`).
3838

39-
include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=index]
39+
`<target>`::
40+
(Optional, string) Comma-separated list of data streams or indices used to limit
41+
the request. Supports wildcards (`*`). To target all data streams and indices,
42+
omit this parameter or use `*` or `_all`.
4043

4144
[[alias-exists-api-query-params]]
4245
==== {api-query-parms-title}
@@ -45,28 +48,17 @@ include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=expand-wildcards]
4548
+
4649
Defaults to `all`.
4750

48-
include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=index-ignore-unavailable]
51+
`ignore_unavailable`::
52+
(Optional, Boolean) If `false`, requests that include a missing data stream or
53+
index in the `<target>` return an error. Defaults to `false`.
4954

5055
include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=local]
5156

52-
5357
[[alias-exists-api-response-codes]]
5458
==== {api-response-codes-title}
5559

5660
`200`::
57-
Indicates all specified index aliases exist.
58-
59-
`404`::
60-
Indicates one or more specified index aliases **do not** exist.
61-
61+
All specified aliases exist.
6262

63-
[[alias-exists-api-example]]
64-
==== {api-examples-title}
65-
66-
[source,console]
67-
----
68-
HEAD /_alias/2030
69-
HEAD /_alias/20*
70-
HEAD /logs_20302801/_alias/*
71-
----
72-
// TEST[s/^/PUT logs_20302801\nPUT logs_20302801\/_alias\/2030\n/]
63+
`404`::
64+
One or more of the specified aliases don't exist.

0 commit comments

Comments
 (0)