AWS ElasticSearch PreBuiltTransportClient java.lang.NoSuchMethodError

时间:2017-05-04 12:31:54

标签: java amazon-web-services elasticsearch

我在Eclipse IDE中创建了一个Java项目,并且在类中有这个代码。我已经包含了所有jar文件依赖项。

angularjs

但是当我运行代码时会出现此错误,

TransportClient client = new PreBuiltTransportClient(Settings.EMPTY,Arrays.asList(
                Netty3Plugin.class,
                Netty4Plugin.class,
                ReindexPlugin.class,
                PercolatorPlugin.class,
                MustachePlugin.class))
        .addTransportAddress(new InetSocketTransportAddress(InetAddress
                .getByName("https://search-my-test-domain-XXXXXXXXXXXXXXXXXXXXXX.us-east-1.es.amazonaws.com"), 9300));

我正在使用elasticsearch v5.3.2并使用java api v5.3。任何解决方案?

1 个答案:

答案 0 :(得分:0)

您不需要指定这五个插件,因为PreBuiltTransportClient构造函数默认已加载它们in the source code of PreBuiltTransportClient

所以请改用:

TransportClient client = new PreBuiltTransportClient(Settings.EMPTY)
    .addTransportAddress(new InetSocketTransportAddress(InetAddress
            .getByName("https://search-my-test-domain-XXXXXXXXXXXXXXXXXXXXXX.us-east-1.es.amazonaws.com"), 9300));

但是,由于您尝试访问AWS托管的ES群集,只知道不支持传输客户端,您只能通过HTTP而不是通过TCP访问AWS ES实例。您将收到的下一个错误是该节点不可用。