现有一个项目,之前用的Lucene 4.3,现在希望加入ElasticSearch2.1.1,但在获取Client时,出现报错,请问可不可以通过设置兼容一下版本,该如何才能解决这个问题?
程序及错误代码如下:
Settings settings = Settings.settingsBuilder().put("utm_search", "es1").build(); TransportClient client = TransportClient.builder().settings(settings).build(); InetAddress address = InetAddress.getByAddress(getIPbytes("192.168.0.54")); client.addTransportAddress(new InetSocketTransportAddress(address, 9200));
Caused by: org.springframework.beans.BeanInstantiationException: Could not instantiate bean class [mysearch.index.ESIndexManager]: Constructor threw exception; nested exception is java.lang.NoSuchFieldError: LUCENE_4_0_0 at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:163) at org.springframework.beans.factory.support.SimpleInstantiationStrategy.instantiate(SimpleInstantiationStrategy.java:87) at org.springframework.beans.factory.support.AbstractAutowireCapableBeanFactory.instantiateBean(AbstractAutowireCapableBeanFactory.java:1004) ... 13 more Caused by: java.lang.NoSuchFieldError: LUCENE_4_0_0 at org.elasticsearch.Version.<clinit>(Version.java:44) at org.elasticsearch.client.transport.TransportClient$Builder.build(TransportClient.java:128) at mysearch.index.ESWrapper.<clinit>(ESWrapper.java:23) at mysearch.index.ESIndexManager.<init>(ESIndexManager.java:32) at sun.reflect.NativeConstructorAccessorImpl.newInstance0(Native Method) at sun.reflect.NativeConstructorAccessorImpl.newInstance(NativeConstructorAccessorImpl.java:57) at sun.reflect.DelegatingConstructorAccessorImpl.newInstance(DelegatingConstructorAccessorImpl.java:45) at java.lang.reflect.Constructor.newInstance(Constructor.java:526) at org.springframework.beans.BeanUtils.instantiateClass(BeanUtils.java:148) ... 15 more
注:
at mysearch.index.ESWrapper.<clinit>(ESWrapper.java:23) 即程序中的第二行
es也是和lucene版本号一一对应的,ElasticSearch2.1.1的lucene对应什么版本号,你下载一个Lucene4.3的es应该就可以
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。