Determine success of call to High Level Rest Client synchronous method

I am beginning to use the 5.6.4 High Level Rest Client. With respect to using for example the index(indexRequest) method, it returns an IndexResponse. I see the methods available like status and shards, etc...

My question is what exactly do I query in the *Response objects to determine if the operation was successful? Is it safe to assume that if I receive a *Response object from a call to the High Level Rest Client that the operation was successful?

Hi Kevin,
the high-level REST client exposes everything that's being returned at REST. With the index API, when the sync call returns an IndexResponse it means that the operation was successful, otherwise an exception would have been thrown (in case for instance a non 2xx response was returned). If you want to know more about whether the replication of the document, if something failed for instance on some replica, then you should check the shards section through the getShardInfo() method, which gives you access to successful, failed, total and failures. See the index API docs here: https://www.elastic.co/guide/en/elasticsearch/reference/5.6/docs-index_.html and also the docs for the high-level REST client: https://www.elastic.co/guide/en/elasticsearch/client/java-rest/5.6/java-rest-high-document-index.html .

Cheers
Luca

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