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]"))
我得到一个错误信息说,该文件尚未创建。如何解释可变数量字段的文档?我该如何创建索引,如果它尚未创建,然后随着我去更新?