bulk insert not working - newline separated JSON body not working
See original GitHub issue🐛 Bug Report
Cannot insert newline separate JSON
To Reproduce
const v = lst.map(v => JSON.stringify({doc: v.value})).join('\n') + '\n';
client.bulk({
index: 'foo',
body: v
})
.catch(e => {
log.error(e);
});
I get this error:
ResponseError: illegal_argument_exception
at IncomingMessage.<anonymous> (/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)
Why doesn’t the stack trace give me more to work with btw? ResponseError: illegal_argument_exception
with no further information does not give me much to work with 😦
Your Environment
- node version: 12
- “@elastic/elasticsearch”: “^7.3.0”,
- os: Mac
This however does work fine:
client.index({
index: 'foo',
body: {
doc: v.value
}
})
.catch(e => {
log.error(e);
});
Issue Analytics
- State:
- Created 4 years ago
- Comments:6 (3 by maintainers)
Top Results From Across the Web
NewLine error in Elasticsearch bulk API post request
I am using elasticsearch service on AWS through a lambda function and trying to post this data using aws NodeHttpClient. Not sure how...
Read more >Loading line-delimited JSON files in SQL Server 2016
Loading Line-Delimited JSON files in SQL Server. One of the problem with JSON is the fact that you cannot continuously append JSON messages....
Read more >How to handle newlines in JSON
First, we need to declare a variable as “json1” and then we need to assign the JSON to it. · In JSON object...
Read more >Bulk API | Elasticsearch Guide [8.5]
The request body contains a newline-delimited list of create , delete , index , and update actions and their associated source data.
Read more >Create issues using the CSV importer | Jira Work ...
Tips for importing CSV data into issue fields ; Comment Body. You can import issues with multiple comments by entering each comment in...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
What is
log
in your code?Take this example to reproduce the error:
The code above produces the following log on Node.js v12:
As you can see, the full error object is logged and the properties are there. I think you are using a custom logger that does not know how to serialize the Error objects, and by default, it logs only the error message and stacktrace.
Hello! If you inspect the error object you should be able to see many other fields. Unfortunately, they are not well documented in the docs, I’ll take care of this. In the meantime, you can find the error classes here: https://github.com/elastic/elasticsearch-js/blob/f7be49f2bafa3b9ddc90b0caac5b70932e6db35b/lib/errors.js#L71-L94
Regarding the bulk body, I think you are not creating the body correctly. I would suggest you take a look at this example 😃