Skip to content

Commit 2369299

Browse files
brwebrusic
authored andcommitted
Make PUT and DELETE consistent for _mapping, _alias and _warmer
See issue elastic#4071 PUT options for _mapping: Single type can now be added with `[PUT|POST] {index|_all|*|regex|blank}/[_mapping|_mappings]/type` and `[PUT|POST] {index|_all|*|regex|blank}/type/[_mapping|_mappings]` PUT options for _warmer: PUT with a single warmer can now be done with `[PUT|POST] {index|_all|*|prefix*|blank}/{type|_all|*|prefix*|blank}/[_warmer|_warmers]/warmer_name` PUT options for _alias: Single alias can now be PUT with `[PUT|POST] {index|_all|*|prefix*|blank}/[_alias|_aliases]/alias` DELETE options _mapping: Several mappings can be deleted at once by defining several indices and types with `[DELETE] /{index}/{type}` `[DELETE] /{index}/{type}/_mapping` `[DELETE] /{index}/_mapping/{type}` where `index= * | _all | glob pattern | name1, name2, …` `type= * | _all | glob pattern | name1, name2, …` Alternatively, the keyword `_mapings` can be used. DELETE options for _warmer: Several warmers can be deleted at once by defining several indices and names with `[DELETE] /{index}/_warmer/{type}` where `index= * | _all | glob pattern | name1, name2, …` `type= * | _all | glob pattern | name1, name2, …` Alternatively, the keyword `_warmers` can be used. DELETE options for _alias: Several aliases can be deleted at once by defining several indices and names with `[DELETE] /{index}/_alias/{type}` where `index= * | _all | glob pattern | name1, name2, …` `type= * | _all | glob pattern | name1, name2, …` Alternatively, the keyword `_aliases` can be used.
1 parent cb32d31 commit 2369299

File tree

51 files changed

+2314
-297
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+2314
-297
lines changed

docs/reference/indices/aliases.asciidoc

Lines changed: 18 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -153,17 +153,22 @@ curl -XGET 'http://localhost:9200/alias2/_search?q=user:kimchy&routing=2,3'
153153

154154
[float]
155155
[[alias-adding]]
156-
=== Add a single index alias
156+
=== Add a single alias
157157

158-
There is also an api to add a single index alias, with options:
158+
An alias can also be added with the endpoint
159+
160+
`PUT /{index}/_alias/{name}`
161+
162+
163+
where
159164

160165
[horizontal]
161-
`index`:: The index to alias refers to. This is a required option.
162-
`alias`:: The name of the alias. This is a required option.
166+
`index`:: The index to alias refers to. Can be any of `blank | * | _all | glob pattern | name1, name2, …`
167+
`name`:: The name of the alias. This is a required option.
163168
`routing`:: An optional routing that can be associated with an alias.
164169
`filter`:: An optional filter that can be associated with an alias.
165170

166-
The rest endpoint is: `/{index}/_alias/{alias}`.
171+
You can also use the plural `_aliases`.
167172

168173
[float]
169174
==== Examples:
@@ -191,16 +196,18 @@ curl -XPUT 'localhost:9200/users/_alias/user_12' -d '{
191196

192197
[float]
193198
[[deleting]]
194-
=== Delete a single index alias
199+
=== Delete aliases
200+
201+
202+
The rest endpoint is: `/{index}/_alias/{name}`
195203

196-
Th API to delete a single index alias, has options:
204+
where
197205

198206
[horizontal]
199-
`index`:: The index the alias is in, the needs to be deleted. This is
200-
a required option.
201-
`alias`:: The name of the alias to delete. This is a required option.
207+
`index`:: `* | _all | glob pattern | name1, name2, …`
208+
`name`:: `* | _all | glob pattern | name1, name2, …`
202209

203-
The rest endpoint is: `/{index}/_alias/{alias}`. Example:
210+
Alternatively you can use the plural `_aliases`. Example:
204211

205212
[source,js]
206213
--------------------------------------------------
Lines changed: 19 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,25 @@
11
[[indices-delete-mapping]]
22
== Delete Mapping
33

4-
Allow to delete a mapping (type) along with its data. The REST endpoint
5-
is `/{index}/{type}` with `DELETE` method.
4+
Allow to delete a mapping (type) along with its data. The REST endpoints are
5+
6+
[source,js]
7+
--------------------------------------------------
8+
9+
[DELETE] /{index}/{type}
10+
11+
[DELETE] /{index}/{type}/_mapping
12+
13+
[DELETE] /{index}/_mapping/{type}
14+
15+
--------------------------------------------------
16+
17+
where
18+
19+
[horizontal]
20+
21+
`index`:: `* | _all | glob pattern | name1, name2, …`
22+
`type`:: `* | _all | glob pattern | name1, name2, …`
623

724
Note, most times, it make more sense to reindex the data into a fresh
825
index compared to delete large chunks of it.

docs/reference/indices/put-mapping.asciidoc

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -59,3 +59,25 @@ $ curl -XPUT 'http://localhost:9200/kimchy,elasticsearch/tweet/_mapping' -d '
5959
}
6060
'
6161
--------------------------------------------------
62+
63+
All options:
64+
65+
[source,js]
66+
--------------------------------------------------
67+
68+
PUT /{index}/_mapping/{type}
69+
70+
71+
--------------------------------------------------
72+
73+
74+
where
75+
76+
[horizontal]
77+
`{index}`:: `blank | * | _all | glob pattern | name1, name2, …`
78+
79+
`{type}`:: Name of the type to add. Must be the name of the type defined in the body.
80+
81+
82+
Instead of `_mapping` you can also use the plural `_mappings`.
83+
The uri `PUT /{index}/{type}/_mapping` is still supported for backwardscompatibility.

docs/reference/indices/warmers.asciidoc

Lines changed: 41 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -112,25 +112,55 @@ curl -XPUT localhost:9200/test/type1/_warmer/warmer_1 -d '{
112112
}'
113113
--------------------------------------------------
114114

115+
All options:
116+
117+
[source,js]
118+
--------------------------------------------------
119+
120+
PUT _warmer/{warmer_name}
121+
122+
PUT /{index}/_warmer/{warmer_name}
123+
124+
PUT /{index}/{type}/_warmer/{warmer_name}
125+
126+
--------------------------------------------------
127+
128+
129+
where
130+
131+
[horizontal]
132+
`{index}`:: `* | _all | glob pattern | name1, name2, …`
133+
134+
`{type}`:: `* | _all | glob pattern | name1, name2, …`
135+
136+
Instead of `_warmer` you can also use the plural `_warmers`.
137+
138+
139+
115140
[float]
116141
[[removing]]
117-
=== Delete Warmer
142+
=== Delete Warmers
143+
144+
Warmers can be deleted using the following endpoint:
145+
118146

119-
Removing a warmer can be done against an index (or alias / indices)
120-
based on its name. The provided name can be a simple wildcard expression
121-
or omitted to remove all warmers. Some samples:
122147

123148
[source,js]
124149
--------------------------------------------------
125-
# delete warmer named warmer_1 on test index
126-
curl -XDELETE localhost:9200/test/_warmer/warmer_1
127150
128-
# delete all warmers that start with warm on test index
129-
curl -XDELETE localhost:9200/test/_warmer/warm*
130-
131-
# delete all warmers for test index
132-
curl -XDELETE localhost:9200/test/_warmer/
151+
[DELETE] /{index}/_warmer/{name}
152+
133153
--------------------------------------------------
154+
155+
156+
where
157+
158+
[horizontal]
159+
`{index}`:: `* | _all | glob pattern | name1, name2, …`
160+
161+
`{name}`:: `* | _all | glob pattern | name1, name2, …`
162+
163+
Instead of `_warmer` you can also use the plural `_warmers`.
134164

135165
[float]
136166
[[warmer-retrieving]]

rest-api-spec/api/indices.delete_alias.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"methods": ["DELETE"],
55
"url": {
66
"path": "/{index}/_alias/{name}",
7-
"paths": ["/{index}/_alias/{name}"],
7+
"paths": ["/{index}/_alias/{name}", "/{index}/_aliases/{name}"],
88
"parts": {
99
"index": {
1010
"type" : "string",

rest-api-spec/api/indices.delete_mapping.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
"methods": ["DELETE"],
55
"url": {
66
"path": "/{index}/{type}/_mapping",
7-
"paths": ["/{index}/{type}/_mapping", "/{index}/{type}"],
7+
"paths": ["/{index}/{type}/_mapping", "/{index}/{type}", "/{index}/_mapping/{type}", "/{index}/{type}/_mappings", "/{index}/_mappings/{type}"],
88
"parts": {
99
"index": {
1010
"type" : "list",

rest-api-spec/api/indices.delete_warmer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,8 @@
33
"documentation": "http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-warmers.html",
44
"methods": ["DELETE"],
55
"url": {
6-
"path": "/{index}/_warmer",
7-
"paths": ["/{index}/_warmer", "/{index}/_warmer/{name}", "/{index}/{type}/_warmer/{name}"],
6+
"path": "/{index}/_warmer/{name}",
7+
"paths": ["/{index}/_warmer", "/{index}/_warmer/{name}", "/{index}/_warmers", "/{index}/_warmers/{name}"],
88
"parts": {
99
"index": {
1010
"type" : "list",

rest-api-spec/api/indices.put_alias.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
22
"indices.put_alias": {
33
"documentation": "http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-aliases.html",
4-
"methods": ["PUT"],
4+
"methods": ["PUT", "POST"],
55
"url": {
66
"path": "/{index}/_alias/{name}",
7-
"paths": ["/{index}/_alias/{name}", "/_alias/{name}", "/{index}/_alias", "/_alias"],
7+
"paths": ["/{index}/_alias/{name}", "/_alias/{name}", "/{index}/_aliases/{name}", "/_aliases/{name}"],
88
"parts": {
99
"index": {
1010
"type" : "string",

rest-api-spec/api/indices.put_mapping.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,11 @@
44
"methods": ["PUT", "POST"],
55
"url": {
66
"path": "/{index}/{type}/_mapping",
7-
"paths": ["/{index}/{type}/_mapping"],
7+
"paths": ["/{index}/{type}/_mapping", "/{index}/_mapping/{type}", "/_mapping/{type}", "/{index}/{type}/_mappings", "/{index}/_mappings/{type}", "/_mappings/{type}"],
88
"parts": {
99
"index": {
1010
"type" : "list",
11-
"required" : true,
11+
"required" : false,
1212
"description" : "A comma-separated list of index names; use `_all` to perform the operation on all indices"
1313
},
1414
"type": {

rest-api-spec/api/indices.put_warmer.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
11
{
22
"indices.put_warmer": {
33
"documentation": "http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-warmers.html",
4-
"methods": ["PUT"],
4+
"methods": ["PUT", "POST"],
55
"url": {
66
"path": "/{index}/_warmer/{name}",
7-
"paths": ["/{index}/_warmer/{name}", "/{index}/{type}/_warmer/{name}"],
7+
"paths": ["/_warmer/{name}", "/{index}/_warmer/{name}", "/{index}/{type}/_warmer/{name}", "/_warmers/{name}", "/{index}/_warmers/{name}", "/{index}/{type}/_warmers/{name}"],
88
"parts": {
99
"index": {
1010
"type" : "list",

0 commit comments

Comments
 (0)