0
我有一個索引'user',它具有映射字段「first」,「last」和「email」。具有名稱的字段在一個點獲取索引,然後包含該電子郵件的字段在單獨的點獲取索引。我希望這些索引具有相同的id,但對應於一個user_id參數。因此,像這樣:如何用Elasticsearch中的新變量更新索引?
function indexName(client, id, name) {
return client.update({
index: 'user',
type: 'text',
id: id,
body: {
first: name.first
last: name.last
}
})
}
function indexEmail(client, id, email) {
return client.update({
index: 'user',
type: 'text',
id: id,
body: {
email: email
}
})
}
在運行時:
indexName(client, "Jon", "Snow").then(indexEmail(client, "[email protected]"))
我得到一個錯誤信息說,該文件尚未創建。如何解釋可變數量字段的文檔?我該如何創建索引,如果它尚未創建,然後隨着我去更新?