I have an index with documents as follows
{ "StartId": "123a", "EndId": "123b", "Tag": "tag1" }
{ "StartId": "234a", "EndId": "234b", "Tag": "tag2" }
{ "StartId": "345a", "EndId": "345b", "Tag": "tag3" }
{ "StartId": "456a", "EndId": "456b", "Tag": "tag4" }
Now I have a new document
{ "StartId": "567a", "EndId": "567b", "Tag": "tag5" }
If StartId from new doc already exists in the index, I want to update it with the data in new doc else I want to insert the new document.
I know how to upsert by _id
POST test/_update/1
{
"doc": {
"name": "new_name"
},
"doc_as_upsert": true
}
But is it possible to upsert by any field other than _id? If yes, how can I do it?