diff --git a/Persister/ObjectPersister.php b/Persister/ObjectPersister.php index 64cf5db..e1c086d 100644 --- a/Persister/ObjectPersister.php +++ b/Persister/ObjectPersister.php @@ -107,7 +107,15 @@ class ObjectPersister implements ObjectPersisterInterface { $documents = array(); foreach ($objects as $object) { - $documents[] = $this->transformToElasticaDocument($object); + $document = $this->transformToElasticaDocument($object); + + try { + $this->type->getDocument($document->getId()); + } catch (NotFoundException $e) { + $this->type->addDocument($document); + } + + $documents[] = $document; } $this->type->updateDocuments($documents); } @@ -146,4 +154,4 @@ class ObjectPersister implements ObjectPersisterInterface { return $this->transformer->transform($object, $this->fields); } -} \ No newline at end of file +}