Client client = TransportClient.builder().build()
.addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("mon1"),9300));
I am using the above code snippet to create a transport client for my elastic search using java API, but it throws exception for the method InetAddress.getByName()
. Says Unknown Host Exception
. Do I need to create some configuration file for it? If yes, please provide details.
Note :- I am not using a elastic search cluster on my local machine.
InetAddress.getByName throws an unhandled exception "host not found"
Put the entire code in try catch block, It will work. :-)
Note:- Elasticsearch.yml file is needed. Put it in your resources folder if you are using java API
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.