好,我創建了一個彈性的搜索索引稱爲用戶,看起來像這樣:在Elasticsearch
$response = $client->index([
'index' => 'users',
'type' => 'user',
'id' => Auth::user()->id,
'body' => [
'username' => Auth::user()->username,
'name' => Auth::user()->name,
'city' => Auth::user()->getCity(),
],
]);
我已經收錄了一些數據。我想了一個名爲「位置」的新字段添加到該索引,以便它現在將是:
$response = $client->index([
'index' => 'users',
'type' => 'user',
'id' => Auth::user()->id,
'body' => [
'username' => Auth::user()->username,
'name' => Auth::user()->name,
'city' => Auth::user()->getCity(),
'location' => [$origin],
],
]);
我的問題是我怎麼該字段添加到現有的數據。我已經有用戶,但沒有位置字段。我需要的是字段添加到老用戶的數據,這樣當用戶更新他們的信息,他們沒有得到任何碎片失蹤錯誤
{"error":{"root_cause":[{"type":"document_missing_exception","reason":"[user][130]: document missing","shard":"0","index":"users"}],"type":"document_missing_exception","reason":"[user][130]: document missing","shard":"0","index":"users"},"status":404}
我的問題是當我創建索引時,我沒有'location'=> [$ origin]創建它,現在我想將它添加到我的索引中。當我在添加'location'=> [$ origin]之前註冊的用戶信息更新索引時,嘗試更新{「error」:{「root_cause」:[{「type」:「document_missing_exception」 ,「reason」:「[user] [130]:document missing」,「shard」:「0」,「index」:「users」}],「type」:「document_missing_exception」,「reason」:「[user ] [130]:文件丟失「,」碎片「:」0「,」索引「:」用戶「},」狀態「:404} – Luna