简体   繁体   English

为弹性搜索创建传输客户端会引发未知主机异常

[英]creating transport client for elastic search throws unknown host exception

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() .我正在使用上面的代码片段使用 java API 为我的弹性搜索创建传输客户端,但它引发了InetAddress.getByName()方法的异常。 Says Unknown Host Exception .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" InetAddress.getByName 抛出一个未处理的异常“找不到主机”

Put the entire code in try catch block, It will work.将整个代码放在 try catch 块中,它将起作用。 :-) :-)

Note:- Elasticsearch.yml file is needed.注意:-需要 Elasticsearch.yml 文件。 Put it in your resources folder if you are using java API如果您使用的是 java API,请将其放在您的资源文件夹中

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM