ductile
Version:
Elasticsearch Bulk Loader
37 lines (34 loc) • 977 B
JavaScript
// Generated by CoffeeScript 1.11.1
(function() {
module.exports = function(client) {
return function(bulk, callback) {
return bulk.reduce(function(p, c) {
return p.then(function() {
var putmapping, t;
t = c.mapping;
putmapping = function() {
return client.indices.putMapping({
index: t._index,
type: t._type,
body: t._mapping
});
};
return putmapping()["catch"](function(err) {
if (err.status === 404) {
return client.indices.create({
index: t._index
}).then(putmapping);
} else {
throw err;
}
});
});
}, Promise.resolve()).then(function() {
return callback(null, {});
})["catch"](function(err) {
return callback(err);
});
};
};
}).call(this);
//# sourceMappingURL=write-mapping.js.map