# How does rest-high-level client retries?

**URL:** https://forum.opensearch.org/t/how-does-rest-high-level-client-retries/15062
**Category:** OpenSearch Client Libraries
**Tags:** opensearch-java, clients-general
**Created:** [July 12, 2023, 8:35am UTC](https://forum.opensearch.org/t/how-does-rest-high-level-client-retries/15062 "2023-07-12T08:35:24Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![bturgut](https://avatars.discourse-cdn.com/v4/letter/b/c5a1d2/32.png) [@bturgut](https://forum.opensearch.org/u/bturgut)
#### Post date: [July 12, 2023, 8:35am UTC](https://forum.opensearch.org/t/how-does-rest-high-level-client-retries/15062/1 "2023-07-12T08:35:24Z")

</div>

**Versions** (relevant - OpenSearch/Dashboard/Server OS/Browser):

server - OpenSearch 2.5.0  
client - Java High Level Rest Client 2.5.0 ([github](https://github.com/opensearch-project/OpenSearch/tree/2.5.0/client/rest-high-level))

**Questions** :

(Relevant) Question 1 : Even though not well documented (or hard to find), Elasticsearch high level client has a retry logic based on failover (in embedded low level client). See posts from Github and the forum respectively; [1] and [2] Does OpenSearch Java high level client have the same retry logic as Elasticsearch client?

(More Important) Question 2 : If the retry logic works the same (failover), does it fail faster when we execute the same, very recently failed, query?

---

<div class="post-metadata">

### Author: ![bturgut](https://avatars.discourse-cdn.com/v4/letter/b/c5a1d2/32.png) [@bturgut](https://forum.opensearch.org/u/bturgut)
#### Post date: [July 12, 2023, 8:37am UTC](https://forum.opensearch.org/t/how-does-rest-high-level-client-retries/15062/2 "2023-07-12T08:37:33Z")

</div>

**Referenced Links :**  
[1] - [https://github.com/elastic/elasticsearch-java/issues/356#issuecomment-1305523252](https://github.com/elastic/elasticsearch-java/issues/356#issuecomment-1305523252)  
[2] - [https://discuss.elastic.co/t/retry-for-java-high-level-rest-client-es-version-6-1/174240/9](https://discuss.elastic.co/t/retry-for-java-high-level-rest-client-es-version-6-1/174240/9)

---

<div class="post-metadata">

### Author: ![wbeckler](https://avatars.discourse-cdn.com/v4/letter/w/9d8465/32.png) [@wbeckler](https://forum.opensearch.org/u/wbeckler)
#### Post date: [July 13, 2023, 4:40am UTC](https://forum.opensearch.org/t/how-does-rest-high-level-client-retries/15062/3 "2023-07-13T04:40:06Z")

</div>

The opensearch-java client is a fork of the elasticsearch-java client from before the discussion you linked, and no retry logic has been added post-fork. I don’t know about the high-level rest client.

---

<div class="post-metadata">

### Author: ![wbeckler](https://avatars.discourse-cdn.com/v4/letter/w/9d8465/32.png) [@wbeckler](https://forum.opensearch.org/u/wbeckler)
#### Post date: [July 13, 2023, 4:40am UTC](https://forum.opensearch.org/t/how-does-rest-high-level-client-retries/15062/4 "2023-07-13T04:40:39Z")

</div>

If you could share more about your use case, there might be other options, such as flink or data-prepper, where someone has already written retry logic that wraps the client.

---

<div class="post-metadata">

### Author: ![bturgut](https://avatars.discourse-cdn.com/v4/letter/b/c5a1d2/32.png) [@bturgut](https://forum.opensearch.org/u/bturgut)
#### Post date: [July 13, 2023, 7:04am UTC](https://forum.opensearch.org/t/how-does-rest-high-level-client-retries/15062/5 "2023-07-13T07:04:39Z")

</div>

We are trying to migrate from Elasticsearch (6.8.22) to OpenSearch (2.5.0). So, what we are trying to do is achieving a similar behaviour without touching client-side application logic much. Currently, our application is writing to both Elasticsearch and OpenSearch (over a proxy).

Sorry if I added confusion. We don’t use or plan to use the opensearch-java client before our migration is completed. I have added opensearch-java discussion link only for referencing the sentence below :  
“The Low Level Client also does retry when configured when several nodes: on network failure, it will retry up to the number of nodes.”

Otherwise, we use high-level rest client.

---

<div class="post-metadata">

### Author: ![bturgut](https://avatars.discourse-cdn.com/v4/letter/b/c5a1d2/32.png) [@bturgut](https://forum.opensearch.org/u/bturgut)
#### Post date: [July 16, 2023, 5:17pm UTC](https://forum.opensearch.org/t/how-does-rest-high-level-client-retries/15062/6 "2023-07-16T17:17:14Z")

</div>

The answers for the future readers of this topic :

**Answer for Q1** : Yes, the clients, both ES and OS, have the same logic with minor differences. AWS support pointed out that OpenSearch high-level REST client v2.5.0 is practically the fork of Elasticsearch high-level REST client v.7.10.12. In our case, we didn’t configure the client properly for retries/failovers to start with, so both clients didn’t utilise retries at all.

**Answer for Q2** : We decided to wrap the client with an external retrier since we discovered that the client itself doesn’t retry at all. So, this question stays an unknown for us. However, since we have a workaround (no failover + external retrier), there will be no more follow ups from our side.

Cheers!

---

<div class="post-metadata">

### Author: ![system](https://us1.discourse-cdn.com/flex019/uploads/mauve_hedgehog/original/2X/3/33547ea01a5b12dcca2958411d3edd97ae2ea8c1.png) [@system](https://forum.opensearch.org/u/system)
#### Post date: [September 14, 2023, 5:17pm UTC](https://forum.opensearch.org/t/how-does-rest-high-level-client-retries/15062/7 "2023-09-14T17:17:46Z")

</div>

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