【发布时间】:2018-08-30 20:34:29
【问题描述】:
我想在弹性搜索中部分更新我现有的文档,为此我编写了部分更新文档而不是整个文档的更新查询 需要更新的示例数据
{
"took": 1,
"timed_out": false,
"_shards": {
"total": 5,
"successful": 5,
"skipped": 0,
"failed": 0
},
"hits": {
"total": 1,
"max_score": 3.0780919,
"hits": [
{
"_index": "trending",
"_type": "doc",
"_id": "bx-1605773",
"_score": 3.0780919,
"_routing": "1",
"_source": {
"id": "bx-1605773",
"name": "new",
"db_id": 1605773,
"user_id": "u-2",
"box_user": {
"id": 2,
"box_id": 1605773,
"username": "yahoo",
"full_name": "Yahoo1",
"is_private": true
},
"status": "M",
"created_at": "2018-08-30T11:58:10Z",
"type": {
"name": "box",
"parent": "u-2"
},
"box_posts": []
}
}
]
}
}
在本文档中,我只更新了盒子的名称和状态,为此我在 ES 中编写了以下查询
$params = [
'index' => 'trending',
'type' => 'doc',
'id' => $this->prepareId($box->id, 'bx'),
'body' => [
'doc' => [
'name' => $box->name,
]
]
];
try {
$response = $this->client->update($params);
} catch (\Exception $ex) {
return false;
}
但是当我运行这个查询时,我会收到以下异常
{"error":{"root_cause":[{"type":"document_missing_exception","reason":"[doc][bx-1605773]: document missing","index_uuid":"h8kvjFk7S0usH3YBO-697A","shard":"0","index":"trending"}],"type":"document_missing_exception","reason":"[doc][bx-1605773]: document missing","index_uuid":"h8kvjFk7S0usH3YBO-697A","shard":"0","index":"trending"},"status":404}
即使是我在弹性搜索主网站上找到的这个查询
我不知道我在哪里做错了
【问题讨论】:
-
你能展示使用这些
$params的PHP代码吗? -
@Val 我已经更新了我的问题,请查看
标签: php elasticsearch