Skip to content

Commit 1edcaca

Browse files
authored
#92162 delete by query (#5)
1 parent 4e74efe commit 1edcaca

File tree

3 files changed

+26
-0
lines changed

3 files changed

+26
-0
lines changed

src/Concerns/InteractsWithIndex.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,14 @@ public function search(array $dsl): array
3232
return $this->resolveClient()->search($this->indexName(), $dsl);
3333
}
3434

35+
/**
36+
* @see SearchIndex::search()
37+
*/
38+
public function deleteByQuery(array $dsl): array
39+
{
40+
return $this->resolveClient()->deleteByQuery($this->indexName(), $dsl);
41+
}
42+
3543
public function isCreated(): bool
3644
{
3745
return $this->resolveClient()->indicesExists($this->indexName());

src/Contracts/SearchIndex.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,4 +18,12 @@ public function tiebreaker(): string;
1818
* @return array
1919
*/
2020
public function search(array $dsl): array;
21+
22+
/**
23+
* Perform delete by query.
24+
*
25+
* @param array $dsl
26+
* @return array
27+
*/
28+
public function deleteByQuery(array $dsl): array;
2129
}

src/ElasticClient.php

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,16 @@ public function search(string $indexName, array $dsl): array
2525
]);
2626
}
2727

28+
public function deleteByQuery(string $indexName, array $dsl): array
29+
{
30+
$this->queryLog?->log($indexName, $dsl);
31+
32+
return $this->client->deleteByQuery([
33+
'index' => $indexName,
34+
'body' => $dsl,
35+
]);
36+
}
37+
2838
public function get(string $indexName, $id): array
2939
{
3040
return $this->client->get([

0 commit comments

Comments
 (0)