Elasticsearch Java Rest客户端:如何获取所有索引的列表
如何使用Rest客户端获取Elasticsearch中所有索引的列表 (我在网上找到的所有答案似乎都是针对老客户的 我在文件里找不到直接的答案Elasticsearch Java Rest客户端:如何获取所有索引的列表,java,
elasticsearch,Java,
elasticsearch,如何使用Rest客户端获取Elasticsearch中所有索引的列表 (我在网上找到的所有答案似乎都是针对老客户的 我在文件里找不到直接的答案 无法确定要查看哪个部分(群集或索引API等)。通过REST API,您可以使用以下URL进行验证: 通过Java客户端API(我刚刚意识到您是这样问的):您可以在集群健康API上下注: 和使用 ClusterHealthRequest request = new ClusterHealthRequest(); ClusterHealthResponse
无法确定要查看哪个部分(群集或索引API等)。通过REST API,您可以使用以下URL进行验证: 通过Java客户端API(我刚刚意识到您是这样问的):您可以在集群健康API上下注: 和使用
ClusterHealthRequest request = new ClusterHealthRequest();
ClusterHealthResponse response = client.cluster().health(request, RequestOptions.DEFAULT);
Set<String> indices = response.getIndices().keySet();
ClusterHealthRequest请求=新的ClusterHealthRequest();
ClusterHealthResponse=client.cluster().health(request,RequestOptions.DEFAULT);
设置索引=response.getindex().keySet();
您将得到索引列表;) 在当前的Java高级REST客户机中,只需请求一个带有“*”的索引名,就可以列出所有索引
GetIndexRequest request = new GetIndexRequest().indices("*");
GetIndexResponse response = client.indices().get(request, RequestOptions.DEFAULT);
String[] indices = response.getIndices();
这个答案应该有助于: