diff --git a/lib/elastic.js b/lib/elastic.js index 81ad606..74f528c 100644 --- a/lib/elastic.js +++ b/lib/elastic.js @@ -33,15 +33,17 @@ elastic.deleteTemplate = function () { }; elastic.setTemplate = function () { - client.indices.putTemplate({ - create: true, - name: TEMPLATE_NAME, - body: templateMapping - }, function (err) { - if (err) { - throw err; - } - gutil.log(chalk.green('Template added:', TEMPLATE_NAME)); + this.deleteTemplate().then(function () { + client.indices.putTemplate({ + create: true, + name: TEMPLATE_NAME, + body: templateMapping + }, function (err) { + if (err) { + throw err; + } + gutil.log(chalk.green('Template added:', TEMPLATE_NAME)); + }); }); };