Handle multiple aliases in _cat/aliases api (#23698)

The alias parameter was documented as a list in our rest-spec, yet only the first value out of a list was getting read and processed. This commit adds support for multiple aliases to _cat/aliases

Closes #23661
This commit is contained in:
Guillaume Le Floch 2017-04-28 15:21:44 +02:00 committed by Luca Cavanna
parent 2412574e49
commit 382a617d34
3 changed files with 50 additions and 3 deletions

View File

@ -46,7 +46,7 @@ public class RestAliasAction extends AbstractCatAction {
@Override
protected RestChannelConsumer doCatRequest(final RestRequest request, final NodeClient client) {
final GetAliasesRequest getAliasesRequest = request.hasParam("alias") ?
new GetAliasesRequest(request.param("alias")) :
new GetAliasesRequest(Strings.commaDelimitedListToStringArray(request.param("alias"))) :
new GetAliasesRequest();
getAliasesRequest.local(request.paramAsBoolean("local", getAliasesRequest.local()));

View File

@ -54,5 +54,6 @@ alias4 test1 - 2 1,2
The output shows that `alias2` has configured a filter, and specific routing
configurations in `alias3` and `alias4`.
If you only want to get information about a single alias, you can specify
the alias in the URL, for example `/_cat/aliases/alias1`.
If you only want to get information about specific aliases, you can specify
the aliases in comma-delimited format as a URL parameter, e.g.,
/_cat/aliases/aliases/alias1,alias2.

View File

@ -126,6 +126,52 @@
- match:
$body: / (^|\n)test_2 .+ \n/
---
"Multiple alias names":
- skip:
version: " - 5.99.99"
reason: multiple aliases are supported only from 6.0.0 on
- do:
indices.create:
index: test
- do:
indices.create:
index: test2
- do:
indices.create:
index: test3
- do:
indices.put_alias:
index: test
name: foo
- do:
indices.put_alias:
index: test2
name: bar
- do:
indices.put_alias:
index: test3
name: baz
- do:
cat.aliases:
name: foo,bar
v: true
h: [alias, index]
s: [index]
- match:
$body: |
/^ alias \s+ index \n
foo \s+ test \n
bar \s+ test2
$/
---
"Column headers":