diff --git a/lib/index.js b/lib/index.js index 10bd513..dfa300d 100644 --- a/lib/index.js +++ b/lib/index.js @@ -5,6 +5,7 @@ var jsonist = require('jsonist') var template = require('lodash').template var once = require('lodash').once var remove_meta = require('ndjson-to-elasticsearch/lib/remove-meta') +var querystring = require("querystring") module.exports = function (config, log, since) { var _retry = async.retry.bind(null, config.retry) @@ -59,7 +60,7 @@ module.exports = function (config, log, since) { if (change.id.indexOf('_design') === 0) return endTask() var doc = change.doc - var es_doc_url = config.elasticsearch + '/' + change.id + var es_doc_url = config.elasticsearch + '/' + querystring.escape(change.id) if (config.key) es_doc_url = config.elasticsearch + '/' + doc[config.key] if (config.urlTemplate) es_doc_url = run_compile(es_doc_url, doc, log) if (doc._deleted) return handle_delete(config, es_doc_url, change, log, onDone, endTask)