Make PUT and DELETE consistent for _mapping, _alias and _warmer
See issue #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.
2014-01-08 04:34:48 -05:00
|
|
|
---
|
|
|
|
setup:
|
|
|
|
# create three indices
|
|
|
|
|
|
|
|
- do:
|
|
|
|
indices.create:
|
|
|
|
index: test_index1
|
|
|
|
- do:
|
|
|
|
indices.create:
|
|
|
|
index: test_index2
|
|
|
|
- do:
|
|
|
|
indices.create:
|
|
|
|
index: foo
|
|
|
|
|
|
|
|
---
|
|
|
|
"put alias per index":
|
|
|
|
|
|
|
|
- do:
|
|
|
|
indices.put_alias:
|
|
|
|
index: test_index1
|
|
|
|
name: alias
|
|
|
|
- do:
|
|
|
|
indices.put_alias:
|
|
|
|
index: test_index2
|
|
|
|
name: alias
|
|
|
|
|
|
|
|
- do:
|
|
|
|
indices.get_alias:
|
|
|
|
name: alias
|
|
|
|
|
|
|
|
- match: {test_index1.aliases.alias: {}}
|
|
|
|
|
|
|
|
- match: {test_index2.aliases.alias: {}}
|
|
|
|
|
|
|
|
- is_false: foo
|
|
|
|
|
|
|
|
---
|
|
|
|
"put alias in _all index":
|
|
|
|
|
|
|
|
- do:
|
|
|
|
indices.put_alias:
|
|
|
|
index: _all
|
|
|
|
name: alias
|
|
|
|
|
|
|
|
- do:
|
|
|
|
indices.get_alias:
|
|
|
|
name: alias
|
|
|
|
|
|
|
|
- match: {test_index1.aliases.alias: {}}
|
|
|
|
- match: {test_index2.aliases.alias: {}}
|
|
|
|
- match: {foo.aliases.alias: {}}
|
|
|
|
|
|
|
|
---
|
|
|
|
"put alias in * index":
|
|
|
|
|
|
|
|
|
|
|
|
- do:
|
|
|
|
indices.put_alias:
|
|
|
|
index: '*'
|
|
|
|
name: alias
|
|
|
|
|
|
|
|
- do:
|
|
|
|
indices.get_alias:
|
|
|
|
name: alias
|
|
|
|
|
|
|
|
- match: {test_index1.aliases.alias: {}}
|
|
|
|
- match: {test_index2.aliases.alias: {}}
|
|
|
|
- match: {foo.aliases.alias: {}}
|
|
|
|
|
|
|
|
---
|
|
|
|
"put alias prefix* index":
|
|
|
|
|
|
|
|
|
|
|
|
- do:
|
|
|
|
indices.put_alias:
|
|
|
|
index: "test_*"
|
|
|
|
name: alias
|
|
|
|
|
|
|
|
- do:
|
|
|
|
indices.get_alias:
|
|
|
|
name: alias
|
|
|
|
|
|
|
|
- match: {test_index1.aliases.alias: {}}
|
|
|
|
- match: {test_index2.aliases.alias: {}}
|
|
|
|
- is_false: foo
|
|
|
|
|
|
|
|
---
|
|
|
|
"put alias in list of indices":
|
|
|
|
|
|
|
|
|
|
|
|
- do:
|
|
|
|
indices.put_alias:
|
|
|
|
index: "test_index1,test_index2"
|
|
|
|
name: alias
|
|
|
|
|
|
|
|
- do:
|
|
|
|
indices.get_alias:
|
|
|
|
name: alias
|
|
|
|
|
|
|
|
- match: {test_index1.aliases.alias: {}}
|
|
|
|
- match: {test_index2.aliases.alias: {}}
|
|
|
|
- is_false: foo
|
|
|
|
|
|
|
|
---
|
|
|
|
"put alias with blank index":
|
|
|
|
|
|
|
|
|
|
|
|
- do:
|
Aliases: Throw exception if index is null or missing when creating an alias
Fixes a bug where alias creation would allow `null` for index name, which thereby
applied the alias to _all_ indices. This patch makes the validator throw an
exception if the index is null.
```bash
POST /_aliases
{
"actions": [
{
"add": {
"alias": "empty-alias",
"index": null
}
}
]
}
```
```json
{
"error": "ActionRequestValidationException[Validation Failed: 1: Alias action [add]: [index] may not be null;]",
"status": 400
}
```
The reason this bug wasn't caught by the existing tests is because
the old test for nullness only validated against a cluster which had
zero indices. The null index is translated into "_all", and since
there are no indices, this fails because the index doesn't exist.
So the test passes.
However, as soon as you add an index, "_all" resolves and you get the
situation described in the original bug report: null index is
accepted by the alias, resolves to "_all" and gets applied to everything.
The REST tests, otoh, explicitly tested this bug as a real feature and therefore
passed. The REST tests were modified to change this behavior.
Fixes #7863
2014-10-27 14:36:28 -04:00
|
|
|
catch: param
|
Make PUT and DELETE consistent for _mapping, _alias and _warmer
See issue #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.
2014-01-08 04:34:48 -05:00
|
|
|
indices.put_alias:
|
|
|
|
name: alias
|
|
|
|
|
|
|
|
|
|
|
|
---
|
2014-02-03 07:23:28 -05:00
|
|
|
"put alias with missing name":
|
Make PUT and DELETE consistent for _mapping, _alias and _warmer
See issue #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.
2014-01-08 04:34:48 -05:00
|
|
|
|
|
|
|
|
|
|
|
- do:
|
|
|
|
catch: param
|
|
|
|
indices.put_alias: {}
|
|
|
|
|