I\'m using FOSElasticaBundle and Doctrine in my project, and my code works for the selective index update using the Doctrine lifecycle events. The issue I come up against is
Sorry, i can not comment under your answer but something is missing in the solution. You have to override preRemove too.
public function preRemove(\Doctrine\Common\EventArgs $eventArgs)
{
$entity = $eventArgs->getEntity();
if ($entity instanceof $this->objectClass) {
$this->scheduleForDeletion($entity);
$this->initialiseJob();
foreach ($entity->getJobOpenings() as $job) {
$this->objectPersisterJob->replaceOne($job);
}
}
}