@@ -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
5549include::{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]
0 commit comments