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

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

Docs show only a localhost sample as

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)

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

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

May be that could help?

Thanks @dadoonet

The terminology is confusing. On careful observation..

On the website, All Products..

In my Elastic Cloud.. I see:

  • Enterprise Search
    • App Search
    • Workplace Search

So, I guess we need to use "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!

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

On cloud:

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 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 or to the on premise service.

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.

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

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.

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