Inserting Elasticsearch Documents in Bulk

We need one more big feature from the esclu command-line tool, and that’s to allow us to bulk-upload documents. Recall that in ​Processing Data Files Sequentially​, we developed an LDJ data file containing interleaved commands and documents for Elasticsearch’s bulk API.

Here’s a truncated sample to refresh your memory:

​ {​"index"​:{​"_id"​:​"pg11"​}}
​ {​"id"​:11,​"title"​:​"Alice's Adventures in Wonderland"​,​"authors"​:...}
​ {​"index"​:{​"_id"​:​"pg132"​}}
​ {​"id"​:132,​"title"​:​"The Art of War"​,​"authors"​:...}

Open your index.js file and insert this new command, again before the program.parse line.

​ 

Get Node.js 8 the Right Way now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.