在我的es索引中有这样的数据:
{
"_index": "pelias",
"_type": "_doc",
"_id": "openaddresses:venue:59a09004887bce7373e117163e5761f1",
"_version": 5,
"_score": 0,
"_source": {
"center_point": {
"lon": 106.633333,
"lat": 10.828199
},
"parent": {
"region": [
"Thành phố Hồ Chí Minh"
],
"region_id": [
"79"
],
"region_a": [
"TPHCM"
],
"county": [
"Quận Tân Bình"
],
"county_id": [
"79766"
],
"county_a": [
"QTB"
],
"locality": [
"Phường 15"
],
"locality_id": [
"7976627007"
],
"locality_a": [
"P15"
]
},
"popularity": 1634576400,
"name": {
"default": "C28 Đường Phan Huy Ích, Phường 15, Tân Bình, Hồ Chí Minh, Việt Nam"
},
"source": "openaddresses",
"source_id": "59a09004887bce7373e117163e5761f1",
"layer": "venue"
}
}现在我想更新center_point。我尝试使用该助手,但它保持返回失败,没有错误描述。这是我的代码:
const result = await client.helpers.bulk({
datasource: updatePayload,
onDocument(doc) {
return [
{ update: { _index: "pelias", _id: doc["_id"] } },
{ doc_as_upsert: false },
];
},
});
console.log(result);用于更新的updatePayload变量:
[ { center_point: { lat: 10.77711802, lon: 106.6937548 },
_id: 'wrong_location:address:faf87656ec9ba08d39b331b5af41e645' },
{ center_point: { lat: 10.78375092, lon: 106.6506849 },
_id: 'wrong_location:address:724f94ada8606c0e8afe0e28c7e82081' }]任何帮助都是非常感谢的。非常感谢。
节点ver: 16.13.1
@弹性/弹性研究: 7.15.0
发布于 2022-04-21 03:42:50
您不是要发送中心点数据,而是尝试以下操作:
const result = await client.helpers.bulk({
datasource: updatePayload,
onDocument(doc) {
return [
{ update: { _index: "pelias", _id: doc["_id"] } },
{ doc_as_upsert: false, "doc": { center_point: doc["center_point"] } },
];
},
});
console.log(result);https://stackoverflow.com/questions/71948540
复制相似问题