Elasticsearch - NoNodeAvailableException

后端 未结 3 450
迷失自我
迷失自我 2020-12-19 02:17

I get the following error when trying to connect to Elasticsearch 2 using the Java API for ES 2. This is the code:

Settings settings = Settings.settingsBuild         


        
3条回答
  •  南方客
    南方客 (楼主)
    2020-12-19 02:38

    The problem might be in the settings that you are using.

    Instead of creating the Client in these three steps:

    TransportClient transportClient = TransportClient.builder().settings(settings).build();
    Client c = null;
    try {
     c = transportClient.addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName(Receptor.es_ip), 9300));
    } catch (UnknownHostException e) {
     System.err.println(Util.getTimestampStr() + "UnknownHostException error.");
     e.printStackTrace();
    }
    

    Try creating it like this:

    Client client = new TransportClient()
                .addTransportAddress(new InetSocketTransportAddress(
                        InetAddress.getByName(Receptor.es_ip),
                        9300));
    

    If you want more data check this old answer to a similar question: Elastic search problems

提交回复
热议问题