如何使用node.js删除弹性搜索中的所有索引?

NYC*_*eer 12 node.js elasticsearch

文件建议以下功能删除特定索引:

client.delete({
  index: 'myindex',
  type: 'mytype',
  id: '1'
}, function (error, response) {
  // ...
});
Run Code Online (Sandbox Code Playgroud)

我已经适应了:

client.delete({
  index: '_all'
}, function (error, response) {
  // ...
});
Run Code Online (Sandbox Code Playgroud)

但是这给了我以下错误:

Unable to build a path with those params. Supply at least index, type, id
Run Code Online (Sandbox Code Playgroud)

我一直在寻找几个小时无济于事,有人有任何想法吗?

NYC*_*eer 23

所以,事实证明我使用的是错误的方法.下面应该注意删除所有索引.

client.indices.delete({
    index: '_all'
}, function(err, res) {

    if (err) {
        console.error(err.message);
    } else {
        console.log('Indexes have been deleted!');
    }
});
Run Code Online (Sandbox Code Playgroud)

您可以在'index'参数中引入特定的索引名称,也可以使用'*'作为'_all'的替代.