Created
January 21, 2015 16:23
-
-
Save jdart/83be40d7d8715467beeb to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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