Skip to content

Instantly share code, notes, and snippets.

@jdart
Created January 21, 2015 16:23
Show Gist options
  • Save jdart/83be40d7d8715467beeb to your computer and use it in GitHub Desktop.
Save jdart/83be40d7d8715467beeb to your computer and use it in GitHub Desktop.
var libxmljs = require("libxmljs");
var fs = require("fs");
var striptags = require('striptags');
var elasticsearch = require('elasticsearch');
var rawXml = fs.readFileSync("data/frag.xml");
var doc = libxmljs.parseXml(rawXml);
var es = new elasticsearch.Client({
host: 'localhost:9200',
log: 'trace'
});
doc.get('//records').childNodes().forEach(function(record) {
es.create({
index: 'blah',
type: 'blah1',
id: record.get("./prod-id").text(),
body: { foo: 'bar' },
ignore: [409]
}).then(function(){
console.log('yay');
}).catch(function(error) {
console.log(error);
});
console.log('???') // i never get here
});
console.log('end')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment