如何使用nodejs驱动程序进行弹性搜索,请实现以下方案。场景是我必须更新"标题"索引中的所有文档,其中给出了电视剧 ID 和给出电视剧编号的位置?
我只想匹配满足这两个查询的文档。我知道我应该使用 client.updateByQuery 方法,但我不确定要为查询正文放置什么。
这个怎么样?您可能需要修改脚本才能更新所需的任何字段。
client.updateByQuery({
index: "title",
type: "type",
body: {
"query": {
"bool": {
"filter": [
{ "term": { "tvSeriesId": 123} },
{ "term": { "tvSeriesNumber": 456} }
]
}
},
"script": {
"inline": "ctx._source.xyz = 'abc'"
}
}
}, function(err, res) {
if (err) {
reportError(err)
}
cb(err, res)
}
)