ClusterHealthRequest

Hi team,
Consider I'm having two indices namely twitter1, twitter2.

String indexpattern = "twitter*"
ClusterHealthRequest request = new ClusterHealthRequest(indexpattern);
ClusterHealthResponse healthResponse = client.cluster().health(request, RequestOptions.DEFAULT);

Here healthResponse.getIndices().entrySet() returns twitter1 and twitter2.

When indexpattern = "twitter1" the healthResponse.getIndices().entrySet() returns twitter1. Thats fine.

But when indexpattern = "twitter" it throws an exception saying java.io.IOException: listener timeout after waiting for [30000] ms after 30 seconds, instead of returning empty set.

Is that normal to throw exception when indices in the cluster doesn't match the pattern?

NOTE: I'm in elasticsearch and elasticsearch-rest-high-level-client version 6.4.0.

Yes. A ClusterHealthRequest for a particular index is a request to be notified when that index has been created. Since the twitter index is never created, the request eventually times out.

So returning empty map rather than throwing timeout exception might be a better option.

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.