Skip to content

Commit 5b30eee

Browse files
committed
catch 404 exception when delete an non-existant item from ES
1 parent ceb1318 commit 5b30eee

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

src/LaravelElasticsearchQueryBuilder.php

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -993,7 +993,12 @@ public function delete($key) {
993993
'type' => $this->type_name,
994994
'id' => $key
995995
];
996-
$result = $this->es_client->delete($params);
996+
try {
997+
$result = $this->es_client->delete($params);
998+
} catch(\Elasticsearch\Common\Exceptions\Missing404Exception $e) {
999+
return false;
1000+
}
1001+
9971002
return $result['found'];
9981003
}
9991004

0 commit comments

Comments
 (0)