JAVA 连接ElasticSearch不成功,帮忙看下 谢谢

美丽De大海 美丽De大海 墨衍会员 · AI 创作全网分发 墨衍智能分发 通过墨衍一键同步至各平台 可同步平台 CSDN微信公众号微博知乎掘金百家号博客园抖音小红书 你的文章也可以这样分发 墨衍会员 ¥399起/年,写一次发全网 我也要 + 加入社区
 public static void main(String[] args) {
Client client = null;
Settings settings = Settings.settingsBuilder()
.put("client.transport.sniff", true)
.put("cluster.name", "elasticsearch").build();
try {
client = TransportClient.builder().settings(settings).build()
.addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("localhost"), 9200));
} catch (UnknownHostException e) {
e.printStackTrace();
}

SearchRequestBuilder sbuilder = client.prepareSearch("megacorp") //index name
.setTypes("employee") //type name
.setSearchType(SearchType.DFS_QUERY_THEN_FETCH)
.setQuery(QueryBuilders.termQuery("first_name", "Douglas")) // Query
.setPostFilter(QueryBuilders.rangeQuery("age").from(20).to(40)) // Filter
.setFrom(0).setSize(60).setExplain(true);
System.out.println(sbuilder.toString());
SearchResponse response = sbuilder.execute().actionGet();
System.out.println(response.toString());
}



错误信息:
Disconnected from the target VM, address: '127.0.0.1:6666', transport: 'socket'
Exception in thread "main" java.lang.VerifyError: (class: org/jboss/netty/channel/socket/nio/NioWorkerPool, method: newWorker signature: (Ljava/util/concurrent/Executor;)Lorg/jboss/netty/channel/socket/nio/AbstractNioWorker;) Wrong return type in function
at org.elasticsearch.transport.netty.NettyTransport.createClientBootstrap(NettyTransport.java:344)
at org.elasticsearch.transport.netty.NettyTransport.doStart(NettyTransport.java:279)
at org.elasticsearch.common.component.AbstractLifecycleComponent.start(AbstractLifecycleComponent.java:68)
at org.elasticsearch.transport.TransportService.doStart(TransportService.java:182)
at org.elasticsearch.common.component.AbstractLifecycleComponent.start(AbstractLifecycleComponent.java:68)
at org.elasticsearch.client.transport.TransportClient$Builder.build(TransportClient.java:162)
at com.lvmama.cobra.job.ESRequest.main(ESRequest.java:26)
...全文
评论 10
收藏 已收藏
分享
返回顶部
美丽De大海
Web 开发 81,108 成员 341,721 内容