elasticsearch,bulkinsert,Node.js,elasticsearch,Bulkinsert" /> elasticsearch,bulkinsert,Node.js,elasticsearch,Bulkinsert" />

Node.js NodeJs和ElasticSearch:大容量插入错误:未能派生xcontent

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',

我找不到我的错误,我正在尝试使用elasticsearch库的bulk方法将元素数组插入到elasticsearch中

提前谢谢

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}…

此外,您正在推进
项目
元素本身,这是您想要的吗