Merge pull request #527 from baggachipz/master
Upsert-type functionality for existing ORM Entities
This commit is contained in:
commit
ff95945819
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue