【发布时间】:2021-08-28 03:19:23
【问题描述】:
输入数据
[{
"_index": "abc",
"_type": "_doc",
"_id": "QAE",
"_score": 6.514091,
"_source": {
"category": "fruits",
"action": "eating",
"metainfo": {
"hash": "nzUZ1ONm0e167p"
},
"createddate": "2019-10-03T12:37:45.297Z"
}},
{
"_index": "abc",
"_type": "_doc",
"_id": "PQR",
"_score": 6.514091,
"_source": {
"category": "Vegetables",
"action": "eating",
"metainfo": {
"hash": "nzUZ1ONm0e167p"
},
"createddate": "2019-10-03T12:37:45.297Z"
}
}-----------------
----------------] 我有大约 30,000 条记录作为输入数据。如何在单个查询中插入此数据。我试过了
var elasticsearch = require('elasticsearch');
var client = new elasticsearch.Client({
host: '********',
log: 'trace'
});
client.index({
index: "abc",
body: ****input data*****
}).then((res) => {
console.log(res);
}, (err) => {
console.log("err", err);
});
在此代码中,在正文中发送输入数据。但它返回一个错误。请给我建议。
【问题讨论】:
-
查看client.bulk
-
我也试过了,但不明白如何在client.bulk.plz中传递输入数据(30,000条记录)你能分享算法吗
-
这个答案应该会有所帮助:stackoverflow.com/a/45604500/4604579 也与这个答案相结合:stackoverflow.com/a/32676238/4604579
标签: node.js express elasticsearch