1

I am trying to index to a remote elastic host but RestHighLevelClient by default is picking up the "localhost:9200" . is there any where i can configure the RestHighLevelClient to use a remote host instead of localhost? I have researched enough on the internet but i could no find anything that could direct me regarding the remote host. I see "localhost" everywhere.

new RestHighLevelClient( RestClient.builder( new HttpHost("http://example.com")));

Any help would be appreciated.

Elastic Version : 6.2.3

Madhu Reddy
  • 371
  • 1
  • 4
  • 12

1 Answers1

0

You need to simply replace http://example.com with your Elasticsearch hostname, for example if Elasticsearch cluster is running on ip 10.10.10.10 and on port 9200, you can give

new RestHighLevelClient( RestClient.builder( new HttpHost("http://10.10.10.10:9200")));

Above value is just a show the example, you need to replace it with your IP which needs to be accessible from the host where you code is running.

Amit
  • 30,756
  • 6
  • 57
  • 88