I am not sure how this can be done though.

Previously, we would do something like this:

```php
$document = new Elastica_Document();
$document->setId(1);
$document->add('counter', 1);
$script = new Elastica_Script('ctx._source.counter += count', array('count' => 4));
$document->setScript($script);

$type->updateDocument($document);
```
In the above, we set the script into the document, and if the document does not exist, the document is used as the upsert.

However, the implementation now is that `Scripts` and `Documents` are first class citizens. So, `setUpsert()` can only ever take a value that is a `Document`. It does not make sense to use a `Script` as an upsert, because it is not possible to do so.

The implementation now is like this:

```php
$upsert = new Document();
$upsert->setData(array('myfield' => 'myvalue'));
$script = new Script('ctx._source.field2 += count; ctx._source.remove("field3")');
$script->setUpsert($upsert);
$script->setId(1); //Will use script to update document 1
$type->updateDocument($script); //Will try to update the document with the script. If it does not exist, upsert using the upsert document.

$upsert = new Document();
$upsert->setData(array('myfield' => 'value'));
$doc = new Document(1, array('myfield' => 'updatedvalue'));
$doc->setUpsert($upsert);
$type->updateDocument($doc); //Will try to update the document with the partial document. If it does not exist, upsert using the upsert document.
```

Notice that we now use `Scripts` and `Documents` as the update. Upsert is only done if people provide a `Document` to `setUpsert()`.

Let me know what you think :)