开发者社区> 问答> 正文

ElasticSearch和Lucene共用时,如何解决版本问题?报错

现有一个项目,之前用的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)    即程序中的第二行


展开
收起
爱吃鱼的程序员 2020-06-10 15:26:36 1018 0
1 条回答
写回答
取消 提交回答
  • https://developer.aliyun.com/profile/5yerqm5bn5yqg?spm=a2c6h.12873639.0.0.6eae304abcjaIB

    es也是和lucene版本号一一对应的,ElasticSearch2.1.1的lucene对应什么版本号,你下载一个Lucene4.3的es应该就可以

    2020-06-10 15:26:54
    赞同 展开评论 打赏
问答排行榜
最热
最新

相关电子书

更多
阿里云Elasticsearch体系架构与特性解析 立即下载
开源与云:Elasticsearch应用剖析 立即下载
《Elasticsearch全观测解决方案》 立即下载