Elasticsearch:获取索引列表 [英] Elasticsearch: get a list of indexes

查看:695
本文介绍了Elasticsearch:获取索引列表的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

是否可以获得与特定模式匹配的索引列表,例如

Is it possible to get a list of indexes that match a certain pattern e.g

这是如何获取索引列表:

this is how to get a list of indexes:

curl -XGET 'localhost:9200/_stats/'

但我找不到一种过滤方式,以便这个列表只包含匹配my_index_nr_1 *的索引,其中*将是通配符

but I couldn't find a way of filter them so that this list would only include only indexes witch match "my_index_nr_1*" where "*" would be a wild card

在使用ES一段时间后,我现在使用的是希望它会帮助别人:

After using ES for quite a while here is what I use now, hope it will help someone else:

curl -XGET '/_cat/indices/my_index_nr_1*'

您还可以在结尾添加?v 。这将为您提供结果中每列的标题。

You can also add ?v at the end which will give you headers of each column in result.

推荐答案

使用_aliases命令有一个整洁的技巧,当与通配符( my_index_nr_1 * )相结合时,只会显示匹配的索引名称和关联的索引:

There is a neat trick using the _aliases command that when combined with a wildcard (my_index_nr_1* below) will only show you matching index names and associated indexes:

curl -XGET 'http://localhost:9200/my_index_nr_1*/_aliases?pretty'

我得到的结果是:

{
  "my_index_nr_1_test" : {
    "aliases" : { }
  }
}

当您在群集上有很多索引但不要想查看所有其他统计资料。

Very helpful when you have a lot of indexes on a cluster but don't want to see all the other stats information.

这篇关于Elasticsearch:获取索引列表的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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