Create ES Client without port in Java

I have ES endpoint on AWS for my ElasticSearch

String endPoint = "https://.........amazonaws.com";
I would like to create Client using Java.
https://www.elastic.co/guide/en/elasticsearch/client/java-api/1.7/transport-client.html
In this example, the way they creating Client is:

Client client = new TransportClient()
        .addTransportAddress(new InetSocketTransportAddress("host1", 9300))
        .addTransportAddress(new InetSocketTransportAddress("host2", 9300));

I am not sure, what port I should use to create my client? I do not have any info what port to use?

Another way to create Client is using Node Client:
https://www.elastic.co/guide/en/elasticsearch/client/java-api/1.7/node-client.html

Node node = nodeBuilder().clusterName("yourclustername").node();
Client client = node.client();

But I am not sure what to use and where to get clusterName for second option?

I have ES endpoint on AWS for my ElasticSearch

Is it something you are running by yourself? Or a service?

https://www.elastic.co/guide/en/elasticsearch/client/java-api/1.7/transport-client.html

Why are you using 1.7 docs? 1.7 is not supported anymore.

I am not sure, what port I should use to create my client? I do not have any info what port to use?

By default elasticsearch runs on 9200 for the REST API and 9300 for the Transport Layer.

Another way to create Client is using Node Client:

Bad idea. The client node has been removed in 2.x and you can not embed an elasticsearch node anymore. Better to use the REST Client IMO.

My team is using old ES version :frowning: And I cannot do anything about it.
My team has ES cluster on AWS, we running our Service there.

What is IMO in REST Client IMO ?

Thanks,
Natalia

IMO = In My Opinion

You should use the Transport Client instead. See https://www.elastic.co/guide/en/elasticsearch/client/java-api/1.7/transport-client.html

Make sure you made port 9300 accessible for the machine which is running the Client.

:warning: do not expose your server on internet!

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