@@ -8,158 +8,47 @@ Adds a data stream or index to an <<alias,alias>>.
8
8
9
9
[source,console]
10
10
----
11
- PUT / my-index-000001 /_alias/alias1
11
+ PUT my-data-stream /_alias/my-alias
12
12
----
13
- // TEST[setup:my_index ]
14
-
13
+ // TEST[setup:my_data_stream ]
14
+ // TEST[teardown:data_stream_cleanup]
15
15
16
16
[[add-alias-api-request]]
17
17
==== {api-request-title}
18
18
19
- `PUT /<index >/_alias/<alias>`
19
+ `POST <target >/_alias/<alias>`
20
20
21
- `POST /<index>/_alias /<alias>`
21
+ `POST <target>/_aliases /<alias>`
22
22
23
- `PUT /<index>/_aliases /<alias>`
23
+ `PUT <target>/_alias /<alias>`
24
24
25
- `POST /<index >/_aliases/<alias>`
25
+ `PUT <target >/_aliases/<alias>`
26
26
27
27
[[add-alias-api-prereqs]]
28
28
==== {api-prereq-title}
29
29
30
30
* 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.
32
33
33
34
[[add-alias-api-path-params]]
34
35
==== {api-path-parms-title}
35
36
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
-
46
37
`<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>>.
50
40
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.
51
45
52
46
[[add-alias-api-query-params]]
53
47
==== {api-query-parms-title}
54
48
55
49
include::{es-repo-dir}/rest-api/common-parms.asciidoc[tag=timeoutparms]
56
50
57
-
58
51
[[add-alias-api-request-body]]
59
52
==== {api-request-body-title}
60
53
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