您有一个带有两个文档的Elasticsearch索引:
[
{
"_index": "myIndex",
"_type": "myType",
"_id": "es1472002807930",
"_source": {
"animal": "turtle",
"color": "green",
"weight": 20,
}
},
{
"_index": "myIndex",
"_type": "myType",
"_id": "es1472002809463",
"_source": {
"animal": "bear",
"color": "brown"
"weight": 400,
}
}
]
Run Code Online (Sandbox Code Playgroud)
稍后,您将获得有关熊的更新数据:
{
"color": "pink",
"weight": 500,
"diet": "omnivore",
}
Run Code Online (Sandbox Code Playgroud)
因此,您想要更新熊的"颜色"和"重量"值,并将"饮食"键添加到"熊"文档中.你知道只有一个doc "animal": "bear"
(但你不知道_id):
使用Nodejs驱动程序,updateByQuery语法会使用这些新值更新"bear"doc吗?
(注意:这个问题已被完全编辑,对SO社区更有用!)