RestHighLevelClient to index the documents to a remote host?

106 Views Asked by At

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

1

There are 1 best solutions below

0
Amit On

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.