O'Reilly logo

Node.js 8 the Right Way by Jim Wilson

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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.

 program
  .command(​'bulk <file>'​)
  .description(​'read and perform bulk options ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required