如果删除了文档,则带有upsert的Elasticsearch更新不起作用

时间:2018-12-10 14:31:38

标签: php elasticsearch

查看文档here:建议我可以传递文档进行更新,如果不存在该文档,请插入它,但是出现以下错误:

  

_index“:”产品“,” _ type“:”产品“,” _ id“:” 66“,” _ version“:1,”结果“:”未找到

此错误是正确的,因为ID为66的文档不再存在,因此我希望它插入而不是更新。我显然可以进行2个查询,检查是否存在,然后进行相应的更新/插入,但是为什么这个请求没有按我的预期插入?

           $params = [
                'index' => 'products',
                'type' => 'product',
                'id' => $product['id'],
                'body' => [
                    'doc' => [
                        'manufacturer' => $product['manufacturer'],
                        ...
                        ...
                    ],
                    'doc_as_upsert' => true
                ]
            ];

            $response = $client->update($params);

0 个答案:

没有答案
相关问题