/_cat/shards should support wilcards for indices

closes #19634
This commit is contained in:
Tanguy Leroux 2016-07-28 15:53:28 +02:00
parent 87a4995bed
commit 737db98bd7
5 changed files with 164 additions and 1 deletions

View File

@ -73,6 +73,7 @@ public class RestShardsAction extends AbstractCatAction {
public void processResponse(final ClusterStateResponse clusterStateResponse) {
IndicesStatsRequest indicesStatsRequest = new IndicesStatsRequest();
indicesStatsRequest.all();
indicesStatsRequest.indices(indices);
client.admin().indices().stats(indicesStatsRequest, new RestResponseListener<IndicesStatsResponse>(channel) {
@Override
public RestResponse buildResponse(IndicesStatsResponse indicesStatsResponse) throws Exception {

View File

@ -25,7 +25,7 @@ some bandwidth by supplying an index pattern to the end.
[source,sh]
--------------------------------------------------
% curl 192.168.56.20:9200/_cat/shards/wiki2
% curl 192.168.56.20:9200/_cat/shards/wiki*
wiki2 0 p STARTED 197 3.2mb 192.168.56.10 Stiletto
wiki2 1 p STARTED 205 5.9mb 192.168.56.30 Frankie Raye
wiki2 2 p STARTED 275 7.8mb 192.168.56.20 Commander Kraken

View File

@ -69,3 +69,50 @@
\s*
)
$/
---
"Test cat indices using wildcards":
- do:
indices.create:
index: foo
body:
settings:
number_of_shards: "1"
number_of_replicas: "0"
- do:
indices.create:
index: bar
body:
settings:
number_of_shards: "1"
number_of_replicas: "0"
- do:
indices.create:
index: baz
body:
settings:
number_of_shards: "1"
number_of_replicas: "0"
- do:
cat.indices:
index: f*
v: false
h: i
- match:
$body: |
/^(foo \n?)$/
- do:
cat.indices:
index: ba*
v: false
h: i
- match:
$body: |
/^(ba(r|z) \n?){2}$/

View File

@ -114,3 +114,71 @@
catch: forbidden
cat.segments:
index: index1
---
"Test cat segments using wildcards":
- do:
indices.create:
index: foo
body:
settings:
number_of_shards: "1"
number_of_replicas: "0"
- do:
index:
index: foo
type: type
body: { test: foo }
refresh: true
- do:
indices.create:
index: bar
body:
settings:
number_of_shards: "1"
number_of_replicas: "0"
- do:
index:
index: bar
type: type
body: { test: bar }
refresh: true
- do:
indices.create:
index: baz
body:
settings:
number_of_shards: "1"
number_of_replicas: "0"
- do:
index:
index: baz
type: type
body: { test: baz }
refresh: true
- do:
cat.segments:
index: f*
v: false
h: i
- match:
$body: |
/^(foo \n?)$/
- do:
cat.segments:
index: ba*
v: false
h: i
- match:
$body: |
/^(ba(r|z) \n?){2}$/

View File

@ -189,3 +189,50 @@
- match:
$body: |
/^(index3 \s+ \d \s+ (p|s) \s+ ((STARTED|INITIALIZING|RELOCATING) \s+ (\d \s+ (\d+|\d+[.]\d+)(kb|b) \s+)? \d{1,3}.\d{1,3}.\d{1,3}.\d{1,3} \s+ .+|UNASSIGNED \s+) \n?){2}$/
---
"Test cat shards using wildcards":
- do:
indices.create:
index: foo
body:
settings:
number_of_shards: "1"
number_of_replicas: "0"
- do:
indices.create:
index: bar
body:
settings:
number_of_shards: "1"
number_of_replicas: "0"
- do:
indices.create:
index: baz
body:
settings:
number_of_shards: "1"
number_of_replicas: "0"
- do:
cat.shards:
index: f*
v: false
h: i
- match:
$body: |
/^(foo \n?)$/
- do:
cat.shards:
index: ba*
v: false
h: i
- match:
$body: |
/^(ba(r|z) \n?){2}$/