I have this call:
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);
});
I am trying to insert multiple items into ES. The bulk API is here: https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/api-reference.html
but for some reason with the above call I get this error:
ResponseError: illegal_argument_exception at IncomingMessage. (/Users/alex/codes/interos/@interos/elastic-search/node_modules/@elastic/elasticsearch/lib/Transport.js:287:25) at IncomingMessage.emit (events.js:208:15) at endReadableNT (_stream_readable.js:1154:12) at processTicksAndRejections (internal/process/task_queues.js:77:11)
I tried using this:
c.bulk({
method: 'POST',
index: 'foo',
body: lst.map(v => JSON.stringify(v)).join('\n') + '\n'
})
.catch(e => {
log.error(e);
});
used method:POST and ensured there was a newline at the end of the body, still the same error :(