【发布时间】:2019-09-09 23:32:23
【问题描述】:
我有这个电话:
const lst = []; // an array with a few object in it
c.bulk({
index: 'foo',
body: lst.map(v => JSON.stringify(v)).join('\n')
})
.catch(e => {
log.error(e);
});
我正在尝试将多个项目插入 ES。批量 API 在这里: https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/api-reference.html
但由于上述调用的某些原因,我收到此错误:
ResponseError: 非法参数异常在 传入消息。 (/Users/alex/codes/interos/@interos/elastic-search/node_modules/@elastic/elasticsearch/lib/Transport.js:287:25) 在 incomingMessage.emit (events.js:208:15) 在 endReadableNT (_stream_readable.js:1154:12) 在 processTicksAndRejections (内部/进程/task_queues.js:77:11)
我试过用这个:
c.bulk({
method: 'POST',
index: 'foo',
body: lst.map(v => JSON.stringify(v)).join('\n') + '\n'
})
.catch(e => {
log.error(e);
});
使用method:POST 并确保正文末尾有一个换行符,仍然是同样的错误:(
【问题讨论】:
标签: elasticsearch