Merge pull request #527 from baggachipz/master

Upsert-type functionality for existing ORM Entities
This commit is contained in:
Tim Nagel 2014-04-02 08:47:47 +11:00
commit ff95945819

View file

@ -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);
}
}
}