# How to connect to Elastic Cloud's endpoint with search-key using Java client?

**URL:** <https://discuss.elastic.co/t/how-to-connect-to-elastic-clouds-endpoint-with-search-key-using-java-client/298098>\
**Category:** Elastic Search\
**Tags:** elastic-app-search\
**Created:** [February 24, 2022, 12:09am UTC](https://discuss.elastic.co/t/how-to-connect-to-elastic-clouds-endpoint-with-search-key-using-java-client/298098 "2022-02-24T00:09:38Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![ksuren](https://avatars.discourse-cdn.com/v4/letter/k/74df32/32.png) [@ksuren](https://discuss.elastic.co/u/ksuren)\
**Post date:** [February 24, 2022, 12:09am UTC](https://discuss.elastic.co/t/how-to-connect-to-elastic-clouds-endpoint-with-search-key-using-java-client/298098/1 "2022-02-24T00:09:39Z")

</div>

How can i connect to Elastic Cloud \> App Search's Endpoint with "search-key" , when using Java client?

 ![Screen_Shot_2022-02-23_at_5_44_25_PM](https://us1.discourse-cdn.com/elastic/original/3X/d/e/de533430c825884fc91097f4f1831bd9d9ce14f1.png)

[Docs show only a localhost sample](https://www.elastic.co/guide/en/elasticsearch/client/java-api-client/current/connecting.html) as

```auto
RestClient restClient = RestClient.builder(new HttpHost("localhost", 9200)).build();
ElasticsearchTransport transport = new RestClientTransport(restClient, new JacksonJsonpMapper());
ElasticsearchClient client = new ElasticsearchClient(transport);

```

I'm looking for something like this example [using Javascript] ([Connecting | Elasticsearch JavaScript Client [8.4] | Elastic](https://www.elastic.co/guide/en/elasticsearch/client/javascript-api/current/client-connecting.html))

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [February 24, 2022, 4:14am UTC](https://discuss.elastic.co/t/how-to-connect-to-elastic-clouds-endpoint-with-search-key-using-java-client/298098/2 "2022-02-24T04:14:49Z")

</div>

The Rest client is for Elasticsearch and not AppSearch yet AFAIK.

There's no Java client for it: [Programming language clients | Elastic Enterprise Search Documentation [8.0] | Elastic](https://www.elastic.co/guide/en/enterprise-search/8.0/programming-language-clients.html)

In the past, I used some code from Swiftype. I put it there: [injector/src/main/java/com/swiftype/appsearch at main · dadoonet/injector · GitHub](https://github.com/dadoonet/injector/tree/main/src/main/java/com/swiftype/appsearch)

May be that could help?

---

<div class="post-metadata">

**Author:** ![ksuren](https://avatars.discourse-cdn.com/v4/letter/k/74df32/32.png) [@ksuren](https://discuss.elastic.co/u/ksuren)\
**Post date:** [February 24, 2022, 2:57pm UTC](https://discuss.elastic.co/t/how-to-connect-to-elastic-clouds-endpoint-with-search-key-using-java-client/298098/3 "2022-02-24T14:57:57Z")

</div>

Thanks @dadoonet

The terminology is confusing. On careful observation..

On the website, All Products..

- Enterprise Search
  - Websites, Apps and Workplace search
  - [Enterprise Search Clients](https://www.elastic.co/guide/en/enterprise-search-clients/index.html) does not have Java.

- Elasticsearch
  - Elasticsearch
  - [Elasticsearch Clients](https://www.elastic.co/guide/en/elasticsearch/client/index.html) has Java.

In my Elastic Cloud.. I see:

- Enterprise Search
  - App Search
  - Workplace Search

So, I guess we need to use "[Elasticsearch](https://www.elastic.co/elasticsearch)" and cannot use the "Elastic Cloud" since we would be using Java and it is not ready yet. Under "Elasticsearch \> Deploy on Elastic Cloud" is misleading!

 ![Screen_Shot_2022-02-24_at_8_55_35_AM](https://us1.discourse-cdn.com/elastic/original/3X/e/2/e2e17f1e612847c63e84ca6a941e96962d1aaa0b.png)

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [February 24, 2022, 3:57pm UTC](https://discuss.elastic.co/t/how-to-connect-to-elastic-clouds-endpoint-with-search-key-using-java-client/298098/4 "2022-02-24T15:57:59Z")

</div>

Elasticsearch is part of the Elastic Stack. The stack is deployable on [cloud.elastic.co](http://cloud.elastic.co). There you will have Elasticsearch and Kibana (and other services if needed).

On cloud:

 ![image](https://us1.discourse-cdn.com/elastic/original/3X/0/e/0e18bb8334e13417cb1b5699db12f0e63ba53511.png)

Whenever it's deployed on cloud or on premise, you can use the Elasticsearch Java client to connect to it.

Enterprise Search is a solution running on top of the Elastic Stack. It needs Elasticsearch and Kibana to run.

It can also be deployed on [cloud.elastic.co](http://cloud.elastic.co) or on premise.

For this one, there is no official Java client AFAIK but you can build your own, just like I shared.  
Then it can connect to both [cloud.elastic.co](http://cloud.elastic.co) or to the on premise service.

---

<div class="post-metadata">

**Author:** ![ksuren](https://avatars.discourse-cdn.com/v4/letter/k/74df32/32.png) [@ksuren](https://discuss.elastic.co/u/ksuren)\
**Post date:** [February 24, 2022, 5:52pm UTC](https://discuss.elastic.co/t/how-to-connect-to-elastic-clouds-endpoint-with-search-key-using-java-client/298098/5 "2022-02-24T17:52:47Z")

</div>

Thanks @dadoonet

I ran another deployment on Elastic Cloud. I removed "Enterprise Search" and opted for Elasticsearch and Kibana. I do not see the "Elasticsearch" option.

 ![Screen Shot 2022-02-24 at 11.46.51 AM](https://us1.discourse-cdn.com/elastic/original/3X/9/b/9b0a994588ccaa28cfb5759aa707ca9508fbb3d8.png)

I do not want to prolong this here. Will reach out to cloud team to see if someone can help us.

---

<div class="post-metadata">

**Author:** ![dadoonet](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dadoonet/32/137187_2.png) [@dadoonet](https://discuss.elastic.co/u/dadoonet)\
**Post date:** [February 24, 2022, 9:12pm UTC](https://discuss.elastic.co/t/how-to-connect-to-elastic-clouds-endpoint-with-search-key-using-java-client/298098/6 "2022-02-24T21:12:58Z")

</div>

When you see this screen, it means that Elasticsearch is running.

Just go to manage this deployment. And you will get the cloud\_id or the Elasticsearch URL.

---

<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:** [March 24, 2022, 9:13pm UTC](https://discuss.elastic.co/t/how-to-connect-to-elastic-clouds-endpoint-with-search-key-using-java-client/298098/7 "2022-03-24T21:13:48Z")

</div>

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