Skip to content

Commit

Permalink
Add validation to check if object exists before deleting it from index (
Browse files Browse the repository at this point in the history
#281)

* Add validation to check if object exists before deleting it from index

This fixes issue #277

It checks if the item exists first in the index before trying to delete it

* Remove unnecessary return in catch validation
  • Loading branch information
DanielLaranjeira063 authored Mar 7, 2025
1 parent b0edd57 commit 06e30f7
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions src/Service.php
Original file line number Diff line number Diff line change
Expand Up @@ -497,8 +497,16 @@ public function doDeleteFromIndex(Concrete $object): void
'id' => $object->getId()
];

$this->logger->info('Deleting data object ' . $object->getId() . ' from es index.');
$this->getClient()->delete($params);
try {
$exists = $this->getClient()->get($params);
} catch (Exception $e){
$exists = false;
$this->logger->debug($e->getMessage());
}
if($exists) {
$this->logger->info('Deleting data object ' . $object->getId() . ' from es index.');
$this->getClient()->delete($params);
}
}

/**
Expand Down

0 comments on commit 06e30f7

Please sign in to comment.