如何使用node.js删除弹性搜索中的所有索引? [英] How do you delete all indexes in elastic search using node.js?

查看:189
本文介绍了如何使用node.js删除弹性搜索中的所有索引?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

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

The documentation recommends the following function to delete a specific index:

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

我已经适应了:

client.delete({
  index: '_all'
}, function (error, response) {
  // ...
});

但是,这给了我以下错误:

But that gives me the following error:

Unable to build a path with those params. Supply at least index, type, id

我一直在搜索几个小时,没有有可能有任何想法吗?

I've been searching around for a couple of hours to no avail, anyone have any ideas?

推荐答案

原来我使用的是错误的方法。下面应该考虑删除所有索引。

So, turns out I was using the wrong method. The below should take care of deleting all the indexes.

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

    if (err) {
        console.error(err.message);
    } else {
        console.log('Indexes have been deleted!');
    }
});

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

You can introduce specific index names within that 'index' parameter, and you can also use '*' as an alternate to '_all'.

这篇关于如何使用node.js删除弹性搜索中的所有索引?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆