Skip to content

Commit c2b10be

Browse files
authored
Merge pull request #61 from ensi-platform/v8-cat-indices
V8 Cat Indices
2 parents 9c32c64 + 591becb commit c2b10be

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

src/Concerns/InteractsWithIndex.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,16 @@ public function catIndices(string $indexName, ?array $getFields = null): array
7171
return $this->resolveClient()->catIndices($indexName, $getFields);
7272
}
7373

74+
public function indicesInfo(array $columns = ['i'], array $sort = [], ?string $health = null): array
75+
{
76+
return $this->resolveClient()->indicesInfo(
77+
indices: [$this->indexName()],
78+
columns: $columns,
79+
sort: $sort,
80+
health: $health
81+
);
82+
}
83+
7484
public function indicesDelete(string $index): array
7585
{
7686
return $this->resolveClient()->indicesDelete($index);

src/ElasticClient.php

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -102,6 +102,32 @@ public function catIndices(string $indexName, ?array $getFields = null): array
102102
return $results;
103103
}
104104

105+
public function indicesInfo(
106+
?array $indices = [],
107+
array $columns = ['i'],
108+
array $sort = [],
109+
?string $health = null
110+
): array {
111+
$params = ['format' => 'json', 'h' => 'i'];
112+
if ($indices) {
113+
$params['index'] = implode(',', $indices);
114+
}
115+
if ($health) {
116+
$params['h'] = $health;
117+
}
118+
if ($columns) {
119+
$params['h'] = implode(',', $columns);
120+
}
121+
if ($sort) {
122+
$params['s'] = implode(',', $sort);
123+
}
124+
125+
return $this->client
126+
->cat()
127+
->indices($params)
128+
->asArray();
129+
}
130+
105131
public function indicesDelete(string $indexName): array
106132
{
107133
return $this->client

0 commit comments

Comments
 (0)