ruflin / Elastica

Elastica is a PHP client for elasticsearch
http://elastica.io/
MIT License
2.26k stars 737 forks source link

Updating using script doesn't support query parameters #509

Open kien-truong opened 10 years ago

kien-truong commented 10 years ago

The current code only set query parameters if $data is of type Document https://github.com/ruflin/Elastica/blob/master/lib/Elastica/Client.php#L278

if ($data instanceof Script) {
    $requestData = $data->toArray();
} elseif ($data instanceof Document) {
ruflin commented 10 years ago

Are all the params which are possible for Document also possible for Script?

kien-truong commented 10 years ago

If I read the docs correctly, at least the following params are supported routing, parent, timeout, replication, consistency, percolate, refresh, fields, retry_on_conflict.

You can verify it here, at the bottom of the page http://www.elasticsearch.org/guide/en/elasticsearch/reference/current/docs-update.html

ruflin commented 10 years ago

So in a way we should mix the query params below line https://github.com/ruflin/Elastica/blob/master/lib/Elastica/Client.php#L316 because here we have Script and Document. Can you open a pull request with these changes and probably add some tests to make sure it works?