gpt4 book ai didi

node.js - elasticsearch js更新索引

转载 作者:行者123 更新时间:2023-12-03 01:25:27 26 4
gpt4 key购买 nike

嗨,大家好,我有一个索引,我想更新使用 flex 搜索js的一部分

例如:我有此索引:

{
"_index" : "users",
"_type" : "j_users",
"_id" : "CpmE0G0BteODhj-lZNPP",
"_score" : 1.0,
"_source" : {
"email" : "alex@walla.co.il",
"firstName" : "aa",
"lastName" : "aa",
"confirmed" : false,

}

并且我只希望将“已确认”字段更改为true,我该怎么做?
await client.update({
index: "users",
id: "CpmE0G0BteODhj-lZNPP",
body: {
confirmed: true
}
});

我根据文档尝试了此操作,但出现错误,有人可以告诉我我的语法有什么问题吗?

最佳答案

试试这个:

await client.update({
index: "users",
type : "j_users"
id: "CpmE0G0BteODhj-lZNPP",
body: {
doc: {
confirmed: true
}
}
});

您也可以尝试添加
 doc_as_upsert: true

关于node.js - elasticsearch js更新索引,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58400145/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com