5
有没有一种方法可以使用Java客户端来获取Elasticsearch中的索引列表?我已经能够找到使用Marvel/Sense这样做的例子,但是我似乎找不到使用Java客户端来做这件事的任何例子。Elasticsearch使用Java客户端查找所有索引
有没有一种方法可以使用Java客户端来获取Elasticsearch中的索引列表?我已经能够找到使用Marvel/Sense这样做的例子,但是我似乎找不到使用Java客户端来做这件事的任何例子。Elasticsearch使用Java客户端查找所有索引
这绝对是可能的,但遗憾的是,它并没有在Java客户端的官方文档中记录。
List<IndexMetaData> indices = client.admin().cluster()
.prepareState().get().getState()
.getMetaData().getIndices();
的另一种方式,我发现做到这一点:
client.admin()
.indices()
.getIndex(new GetIndexRequest())
.actionGet()
.getIndices()
万一别人送过来,并想知道,这个方法返回一个String []这可能是比较容易处理,你可以做到这一点用。 – 2016-09-26 14:55:05
是的..这一个更简单的方法:D – thekucays