# Batch indexing

Example of indexing millions of records from CSV. It was successfully used for indexing tens of millions of records

# Install packages
npm install elasticbulk bluebird JSONStream
// Create import.js function
const JSONStream = require('JSONStream')
const elasticbulk = require('elasticbulk');
const Promise = require('bluebird');
const fs = Promise.promisifyAll(require('fs'));

// config file
const config = require('./config.json');

// comma delimited JSON file
var stream = fs.createReadStream('./items_csv.json').pipe(JSONStream.parse());

(async function() {

  await elasticbulk.import(stream, {
    chunk_size: 20000,
    engine: 'itemsapi',
    index_name: 'index1',
    //api_key: '',
    host: 'http://localhost:3000'
  }, config)