I want to get in programmatic way the data that is available through
/IDXNAME/TYPENAME/_search_shards?routing=route2
Sadly this is not documented in Java API. However I have found that there is a method
client().admin().cluster().searchShards(clusterSearchShardsRequest)
with code like:
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();
}
However the clusterSearchShardsRequest
initialization is incorrect here so for a given (client,index,type). How can one fix this code to give the _search_shard informations?
How can I get the _search_shards
functionality with Java API?