list all index in elasticsearch

方法1

client.admin().indices().stats(new IndicesStatsRequest()).actionGet().getIndices().keySet()

方法2

client.admin().indices().prepareGetIndex().get().getIndices()

以上两种方法都可以列出所有的index,但是这些index都是green状态的索引,即open状态的索引,close状态的索引

下面这个方法可以得到所有的index,包括close状态的索引。

client.admin().cluster().prepareState().execute().actionGet().getState().getMetaData().concreteAllIndices()

原文地址:https://www.cnblogs.com/majw/p/6427553.html