Skip to content

Commit

Permalink
Make PUT and DELETE consistent for _mapping, _alias and _warmer
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
brwe authored and brusic committed Jan 19, 2014
1 parent cb32d31 commit 2369299
Show file tree
Hide file tree
Showing 51 changed files with 2,314 additions and 297 deletions.
29 changes: 18 additions & 11 deletions docs/reference/indices/aliases.asciidoc
Expand Up @@ -153,17 +153,22 @@ curl -XGET 'http://localhost:9200/alias2/_search?q=user:kimchy&routing=2,3'

[float]
[[alias-adding]]
=== Add a single index alias
=== Add a single alias

There is also an api to add a single index alias, with options:
An alias can also be added with the endpoint

`PUT /{index}/_alias/{name}`


where

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

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

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

[float]
[[deleting]]
=== Delete a single index alias
=== Delete aliases


The rest endpoint is: `/{index}/_alias/{name}`

Th API to delete a single index alias, has options:
where

[horizontal]
`index`:: The index the alias is in, the needs to be deleted. This is
a required option.
`alias`:: The name of the alias to delete. This is a required option.
`index`:: `* | _all | glob pattern | name1, name2, …`
`name`:: `* | _all | glob pattern | name1, name2, …`

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

[source,js]
--------------------------------------------------
Expand Down
21 changes: 19 additions & 2 deletions docs/reference/indices/delete-mapping.asciidoc
@@ -1,8 +1,25 @@
[[indices-delete-mapping]]
== Delete Mapping

Allow to delete a mapping (type) along with its data. The REST endpoint
is `/{index}/{type}` with `DELETE` method.
Allow to delete a mapping (type) along with its data. The REST endpoints are

[source,js]
--------------------------------------------------
[DELETE] /{index}/{type}
[DELETE] /{index}/{type}/_mapping
[DELETE] /{index}/_mapping/{type}
--------------------------------------------------

where

[horizontal]

`index`:: `* | _all | glob pattern | name1, name2, …`
`type`:: `* | _all | glob pattern | name1, name2, …`

Note, most times, it make more sense to reindex the data into a fresh
index compared to delete large chunks of it.
22 changes: 22 additions & 0 deletions docs/reference/indices/put-mapping.asciidoc
Expand Up @@ -59,3 +59,25 @@ $ curl -XPUT 'http://localhost:9200/kimchy,elasticsearch/tweet/_mapping' -d '
}
'
--------------------------------------------------

All options:

[source,js]
--------------------------------------------------
PUT /{index}/_mapping/{type}
--------------------------------------------------


where

[horizontal]
`{index}`:: `blank | * | _all | glob pattern | name1, name2, …`

`{type}`:: Name of the type to add. Must be the name of the type defined in the body.


Instead of `_mapping` you can also use the plural `_mappings`.
The uri `PUT /{index}/{type}/_mapping` is still supported for backwardscompatibility.
52 changes: 41 additions & 11 deletions docs/reference/indices/warmers.asciidoc
Expand Up @@ -112,25 +112,55 @@ curl -XPUT localhost:9200/test/type1/_warmer/warmer_1 -d '{
}'
--------------------------------------------------

All options:

[source,js]
--------------------------------------------------
PUT _warmer/{warmer_name}
PUT /{index}/_warmer/{warmer_name}
PUT /{index}/{type}/_warmer/{warmer_name}
--------------------------------------------------


where

[horizontal]
`{index}`:: `* | _all | glob pattern | name1, name2, …`

`{type}`:: `* | _all | glob pattern | name1, name2, …`

Instead of `_warmer` you can also use the plural `_warmers`.



[float]
[[removing]]
=== Delete Warmer
=== Delete Warmers

Warmers can be deleted using the following endpoint:


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

[source,js]
--------------------------------------------------
# delete warmer named warmer_1 on test index
curl -XDELETE localhost:9200/test/_warmer/warmer_1
# delete all warmers that start with warm on test index
curl -XDELETE localhost:9200/test/_warmer/warm*
# delete all warmers for test index
curl -XDELETE localhost:9200/test/_warmer/
[DELETE] /{index}/_warmer/{name}
--------------------------------------------------


where

[horizontal]
`{index}`:: `* | _all | glob pattern | name1, name2, …`

`{name}`:: `* | _all | glob pattern | name1, name2, …`

Instead of `_warmer` you can also use the plural `_warmers`.

[float]
[[warmer-retrieving]]
Expand Down
2 changes: 1 addition & 1 deletion rest-api-spec/api/indices.delete_alias.json
Expand Up @@ -4,7 +4,7 @@
"methods": ["DELETE"],
"url": {
"path": "/{index}/_alias/{name}",
"paths": ["/{index}/_alias/{name}"],
"paths": ["/{index}/_alias/{name}", "/{index}/_aliases/{name}"],
"parts": {
"index": {
"type" : "string",
Expand Down
2 changes: 1 addition & 1 deletion rest-api-spec/api/indices.delete_mapping.json
Expand Up @@ -4,7 +4,7 @@
"methods": ["DELETE"],
"url": {
"path": "/{index}/{type}/_mapping",
"paths": ["/{index}/{type}/_mapping", "/{index}/{type}"],
"paths": ["/{index}/{type}/_mapping", "/{index}/{type}", "/{index}/_mapping/{type}", "/{index}/{type}/_mappings", "/{index}/_mappings/{type}"],
"parts": {
"index": {
"type" : "list",
Expand Down
4 changes: 2 additions & 2 deletions rest-api-spec/api/indices.delete_warmer.json
Expand Up @@ -3,8 +3,8 @@
"documentation": "http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-warmers.html",
"methods": ["DELETE"],
"url": {
"path": "/{index}/_warmer",
"paths": ["/{index}/_warmer", "/{index}/_warmer/{name}", "/{index}/{type}/_warmer/{name}"],
"path": "/{index}/_warmer/{name}",
"paths": ["/{index}/_warmer", "/{index}/_warmer/{name}", "/{index}/_warmers", "/{index}/_warmers/{name}"],
"parts": {
"index": {
"type" : "list",
Expand Down
4 changes: 2 additions & 2 deletions rest-api-spec/api/indices.put_alias.json
@@ -1,10 +1,10 @@
{
"indices.put_alias": {
"documentation": "http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-aliases.html",
"methods": ["PUT"],
"methods": ["PUT", "POST"],
"url": {
"path": "/{index}/_alias/{name}",
"paths": ["/{index}/_alias/{name}", "/_alias/{name}", "/{index}/_alias", "/_alias"],
"paths": ["/{index}/_alias/{name}", "/_alias/{name}", "/{index}/_aliases/{name}", "/_aliases/{name}"],
"parts": {
"index": {
"type" : "string",
Expand Down
4 changes: 2 additions & 2 deletions rest-api-spec/api/indices.put_mapping.json
Expand Up @@ -4,11 +4,11 @@
"methods": ["PUT", "POST"],
"url": {
"path": "/{index}/{type}/_mapping",
"paths": ["/{index}/{type}/_mapping"],
"paths": ["/{index}/{type}/_mapping", "/{index}/_mapping/{type}", "/_mapping/{type}", "/{index}/{type}/_mappings", "/{index}/_mappings/{type}", "/_mappings/{type}"],
"parts": {
"index": {
"type" : "list",
"required" : true,
"required" : false,
"description" : "A comma-separated list of index names; use `_all` to perform the operation on all indices"
},
"type": {
Expand Down
4 changes: 2 additions & 2 deletions rest-api-spec/api/indices.put_warmer.json
@@ -1,10 +1,10 @@
{
"indices.put_warmer": {
"documentation": "http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/indices-warmers.html",
"methods": ["PUT"],
"methods": ["PUT", "POST"],
"url": {
"path": "/{index}/_warmer/{name}",
"paths": ["/{index}/_warmer/{name}", "/{index}/{type}/_warmer/{name}"],
"paths": ["/_warmer/{name}", "/{index}/_warmer/{name}", "/{index}/{type}/_warmer/{name}", "/_warmers/{name}", "/{index}/_warmers/{name}", "/{index}/{type}/_warmers/{name}"],
"parts": {
"index": {
"type" : "list",
Expand Down

0 comments on commit 2369299

Please sign in to comment.