Node.js NodeJs和ElasticSearch:大容量插入错误:未能派生xcontent
我找不到我的错误,我正在尝试使用elasticsearch库的bulk方法将元素数组插入到elasticsearch中 提前谢谢Node.js NodeJs和ElasticSearch:大容量插入错误:未能派生xcontent,node.js,
elasticsearch,bulkinsert,Node.js,
elasticsearch,Bulkinsert,我找不到我的错误,我正在尝试使用elasticsearch库的bulk方法将元素数组插入到elasticsearch中 提前谢谢 InserTweets: function (arrayobj, callback) { var items=[]; var count=1; arrayobj.forEach(element => { items.push({ index: { _index: 'twitter',
InserTweets: function (arrayobj, callback) {
var items=[];
var count=1;
arrayobj.forEach(element => {
items.push({ index: { _index: 'twitter', _type: 'tweet', _id: count }},element);
count++;
});
console.log(items);
client.bulk({body: [items]}, function (err, resp, status) {
callback(err, resp, status);
});
}
错误:
{ error:
{ root_cause: [ [Object] ],
type: 'parse_exception',
reason: 'Failed to derive xcontent' },
status: 400 }
属性
body
的值必须是对象数组,而不是对象数组
这个client.bulk({body:[items]}…
应该是client.bulk({body:items}…
此外,您也要将
项
推入元素
本身,这就是您想要的吗?属性主体
的值必须是一个对象数组,而不是一个对象数组
这个client.bulk({body:[items]}…
应该是client.bulk({body:items}…
此外,您正在推进项目
元素本身,这是您想要的吗