Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The update operation doesn't work #3

Closed
ivannis opened this issue Nov 3, 2014 · 0 comments · Fixed by #4
Closed

The update operation doesn't work #3

ivannis opened this issue Nov 3, 2014 · 0 comments · Fixed by #4

Comments

@ivannis
Copy link
Contributor

ivannis commented Nov 3, 2014

For example, for the given document

<?php
namespace Acme\AcmeDemoBundle\Document;

use ONGR\ElasticsearchBundle\Annotation as ES;
use ONGR\ElasticsearchBundle\Document\DocumentInterface;
use ONGR\ElasticsearchBundle\Document\DocumentTrait;

/**
 * @ES\Document
 */
class Content implements DocumentInterface
{
    use DocumentTrait;

    /**
     * @var string
     *
     * @ES\Property(name="name", type="string")
     */
    private $name;

    /**
     * {@inheritdoc}
     */
    public function getName()
    {
        return $this->name;
    }

    /**
     * {@inheritdoc}
     */
    public function setName($name)
    {
        $this->name = $name;

        return $this;
    }
}

If you create one

$manager = $this->get("es.manager");

$content = new \Acme\AcmeDemoBundle\Document\Content();
$content->setId("myCustomId");
$content->setName("Acme");

$manager->persist($content); 
$manager->commit();

When you try to update an existing document you never can update it

$manager = $this->get("es.manager");
$repository = $manager->getRepository('AcmeDemoBundle:Content');
$document = $repository->find('myCustomId');

$content->setName("Another Name");
$manager->persist($document); // The persist method never send an "update" bulk operation to elasticsearch
$manager->commit();

And look in the index

curl -XGET localhost:9200/my_index/my_type/_search?pretty

The content never change. I think that the problem is in the persist method of the Manager class https://github.com/ongr-io/ElasticsearchBundle/blob/master/ORM/Manager.php#L103-L107 that always sends the "create" operation. The Connection class never send any update option upsert, doc_as_upsert ... in the bulk method https://github.com/ongr-io/ElasticsearchBundle/blob/master/Client/Connection.php#L93-L115

@saimaz saimaz closed this as completed in #4 Nov 4, 2014
heromantor added a commit to heromantor/ElasticsearchBundle that referenced this issue Jan 16, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant