# Can we connect to multiple clusters in JAVA using High level rest client

**URL:** <https://discuss.elastic.co/t/can-we-connect-to-multiple-clusters-in-java-using-high-level-rest-client/333310>\
**Category:** Elasticsearch\
**Tags:** language-clients\
**Created:** [May 12, 2023, 1:45pm UTC](https://discuss.elastic.co/t/can-we-connect-to-multiple-clusters-in-java-using-high-level-rest-client/333310 "2023-05-12T13:45:09Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Umang\_Pachaury](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/umang_pachaury/32/113523_2.png) [@Umang\_Pachaury](https://discuss.elastic.co/u/Umang_Pachaury)\
**Post date:** [May 12, 2023, 1:45pm UTC](https://discuss.elastic.co/t/can-we-connect-to-multiple-clusters-in-java-using-high-level-rest-client/333310/1 "2023-05-12T13:45:10Z")

</div>

Hi team,  
I have a question about high level rest client  
lets suppose  
I have 2 clusters running on two different machines and those clusters have an index with the same name. I have a Java application which fetches data from a single cluster using HLRC. Now I want to connect to both the clusters and want to fire API calls to them so that it can fetch the data from both the indexes on different machines. So can a single client instance connect to multiple clusters and fire a query which fetches data from both the clusters and I also want the combined results of both the request in a single response.

Is this at all possible and if not what can be my best approach to this?

---

<div class="post-metadata">

**Author:** ![warkolm](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/warkolm/32/39224_2.png) [@warkolm](https://discuss.elastic.co/u/warkolm)\
**Post date:** [May 17, 2023, 11:13pm UTC](https://discuss.elastic.co/t/can-we-connect-to-multiple-clusters-in-java-using-high-level-rest-client/333310/2 "2023-05-17T23:13:32Z")

</div>

As far as my understanding is you cannot do this in the client and you need two separate instances.

An alternative may be to use CCS - [Search across clusters | Elasticsearch Guide [8.7] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/8.7/modules-cross-cluster-search.html)

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [June 14, 2023, 11:14pm UTC](https://discuss.elastic.co/t/can-we-connect-to-multiple-clusters-in-java-using-high-level-rest-client/333310/3 "2023-06-14T23:14:16Z")

</div>

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