Skip to content

Commit a07bad4

Browse files
SadDoneSaddam
andauthored
#93726 add methods cat and delete indices (#9)
* #93726 add methods * Fix styling Co-authored-by: Saddam <[email protected]> Co-authored-by: SadDone <[email protected]>
1 parent c3e5661 commit a07bad4

File tree

2 files changed

+25
-0
lines changed

2 files changed

+25
-0
lines changed

src/Concerns/InteractsWithIndex.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,16 @@ public function documentDelete(int $id): array
6565
return $this->resolveClient()->documentDelete($this->indexName(), $id);
6666
}
6767

68+
public function catIndices(string $indexName, ?array $getFields = null)
69+
{
70+
return $this->resolveClient()->catIndices($indexName, $getFields);
71+
}
72+
73+
public function indicesDelete(string $index)
74+
{
75+
return $this->resolveClient()->indicesDelete($index);
76+
}
77+
6878
public static function query(): SearchQuery
6979
{
7080
return new SearchQuery(new static());

src/ElasticClient.php

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -72,6 +72,21 @@ public function documentDelete(string $index, int $id): array
7272
]);
7373
}
7474

75+
public function catIndices(string $indexName, ?array $getFields = null)
76+
{
77+
$params = ['index' => "$indexName*"];
78+
if ($getFields) {
79+
$params['h'] = $getFields;
80+
}
81+
82+
return $this->client->cat()->indices($params);
83+
}
84+
85+
public function indicesDelete(string $index)
86+
{
87+
return $this->client->indices()->delete(['index' => $index]);
88+
}
89+
7590
public function enableQueryLog(): void
7691
{
7792
$this->queryLog ??= new QueryLog();

0 commit comments

Comments
 (0)