Skip to content

Instantly share code, notes, and snippets.

View Darrencwood's full-sized avatar

Darrencwood

View GitHub Profile
@nicholasblexrud
nicholasblexrud / elasticsearchbulkimport.js
Created February 12, 2016 17:40
Bulk upload files using Node.js to Elasticsearch
// credit goes to this stack overflow post - http://stackoverflow.com/questions/20646836/is-there-any-way-to-import-a-json-filecontains-100-documents-in-elasticsearch
var elasticsearch = require('elasticsearch'),
fs = require('fs'),
pubs = JSON.parse(fs.readFileSync(__dirname + '/pubs.json')), // name of my first file to parse
forms = JSON.parse(fs.readFileSync(__dirname + '/forms.json')); // and the second set
var client = new elasticsearch.Client({ // default is fine for me, change as you see fit
host: 'localhost:9200',
log: 'trace'
});