0

我设计了以下代码来获取类似于_search_shardsES 中的 rest API 的信息:

    ClusterSearchShardsRequest clusterSearchShardsRequest 
= new   ClusterSearchShardsRequest();
                clusterSearchShardsRequest.routing("route2");

                try {
                    DiscoveryNode[] discoveryNodes = client().admin().cluster()
                            .searchShards(clusterSearchShardsRequest)
                            .get()
                            .getNodes();
                    for (int i=0; i<=discoveryNodes.length; i++){
                        System.out.print("\n\n\n"+discoveryNodes[i].toString()+"\n\n\n");
                    }

                } catch (InterruptedException e) {
                    e.printStackTrace();
                } catch (ExecutionException e) {
                    e.printStackTrace();
                }

但是,这往往不会初始化实际的clusterSearchShardsRequest.

如何clusterSearchShardsRequest为给定client和索引初始化?

4

1 回答 1

0

只需new ClusterSearchShardsRequest(BOOK_INDEX_NAME)使用索引名称参数创建 。

于 2016-09-01T08:49:24.610 回答