# How to connect es cluster

**URL:** <https://discuss.elastic.co/t/how-to-connect-es-cluster/321712>\
**Category:** Elasticsearch\
**Created:** [December 21, 2022, 2:57am UTC](https://discuss.elastic.co/t/how-to-connect-es-cluster/321712 "2022-12-21T02:57:10Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![duocoding](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/duocoding/32/114989_2.png) [@duocoding](https://discuss.elastic.co/u/duocoding)\
**Post date:** [December 21, 2022, 2:57am UTC](https://discuss.elastic.co/t/how-to-connect-es-cluster/321712/1 "2022-12-21T02:57:10Z")

</div>

```auto
// Create the low-level client
RestClient restClient = RestClient.builder(
    new HttpHost("localhost", 9200)).build();

// Create the transport with a Jackson mapper
ElasticsearchTransport transport = new RestClientTransport(
    restClient, new JacksonJsonpMapper());

// And create the API client
ElasticsearchClient client = new ElasticsearchClient(transport);

```

domo just show how to connect single node, but our service use es-cluster, so i want to know how to connect es cluster, who can help me 😀

---

<div class="post-metadata">

**Author:** ![duocoding](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/duocoding/32/114989_2.png) [@duocoding](https://discuss.elastic.co/u/duocoding)\
**Post date:** [December 21, 2022, 8:39am UTC](https://discuss.elastic.co/t/how-to-connect-es-cluster/321712/2 "2022-12-21T08:39:27Z")

</div>

I've fixed this issue

```auto
RestClient.builder(HttpHost... host)

```

this method support to pass an array

---

<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:** [January 18, 2023, 8:39am UTC](https://discuss.elastic.co/t/how-to-connect-es-cluster/321712/3 "2023-01-18T08:39:50Z")

</div>

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