Divya
Divya

Reputation: 53

Unable to update a document elastica

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?

Upvotes: 0

Views: 867

Answers (1)

ruflin
ruflin

Reputation: 206

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.

Upvotes: 1

Related Questions