phillro/node-elasticsearch-client — pull request #59 by snmaynard (2013-03-01 22:21:08+00:00)
Title: Update shouldnt add doc key to document

Currently the doc key is automatically added to the update payload. However, this means certain operations are not possible, like an [upsert](http://www.elasticsearch.org/guide/reference/api/update.html) for example.

I have a document that contains at the top level a doc key, that should be used for the update, but also an upsert key that should be used if the document doesnt exist. The problem with the code as it currently is, is that it automatically puts all of that inside the doc key. For example

```javascript
//this
{
"doc":{
"key1": "value1"
},
"upsert":{
"key1":"value1",
"key2":"value2"
}
}

//becomes
{
"doc":{
"doc":{
"key1": "value1"
},
"upsert":{
"key1":"value1",
"key2":"value2"
}
}
}
```

I propose that we remove this from the code. It is a breaking change though, as it changes the interface. If you want to keep the interface the same we could add some kind of option to disable the automatic doc adding, but I think this is cleaner in the long run. Unless you can see another solution?