Unable to update a document elastica

854 views Asked by At

I am trying to update a document with script as mentioned below:

$script = new \Elastica\Script( 'ctx._source.fuzzy = value', array( 'value' => 'y' ), 'groovy' );
$script->setId( 1 );
$this->getType()->updateDocument( $script );

I am not able to recognize what is wrong as there is no error message. Am I missing any step in this process?

1

There are 1 answers

0
ruflin On

As you don't get an error, I assume the operation worked as intended. As the updated is by default not immediately available on all shards and I assume you directly check afterwards if it worked, I recommend you to pass the 'refresh' option as following:

$type->updateDocument($script, array('refresh' => true));

A working example can be found here: https://github.com/ruflin/Elastica/blob/master/test/lib/Elastica/Test/TypeTest.php#L609

In the case that this is does not solve the issue, please post also the part where you add the document and query for it to check if it exists for further analysis.