Better upsert implementation

This closes #414 and #413.

I have revamped the upsert implementation. Scripts are now considered first-class citizens and on the same level as Documents.

Thus, to do upsert:
```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.
```

To use upsert_as_doc:
```php
$doc = new Document();
$doc->setData(array('myfield' => 'myvalue'));
$doc->setId(1);
$doc->setUpsertAsDoc(true);
$type->updateDocument($doc); //If the document does not exist, treat the document as an upsert.
```