我设计了以下代码来获取类似于_search_shards
ES 中的 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
和索引初始化?