Looking at the documentation here: it suggests I can pass a doc in for update and if it doesn't exist then insert it but I get the following error:
_index":"products","_type":"product","_id":"66","_version":1,"result":"not_found
This error is correct because the document with id of 66 no longer exists so I want it to insert rather than update. I can obviously do 2 queries, check if it exists then update/insert accordingly but why is this request not inserting as I expect?
$params = [
'index' => 'products',
'type' => 'product',
'id' => $product['id'],
'body' => [
'doc' => [
'manufacturer' => $product['manufacturer'],
...
...
],
'doc_as_upsert' => true
]
];
$response = $client->update($params);