Hello team,
Im running into org.apache.lucene compatibility issue when i try to use elastic and spring-data-opensearch in same project.
I’m using spring-data-opensearch dependency
org.opensearch.client
spring-data-opensearch
1.3.0
Source → GitHub - opensearch-project/spring-data-opensearch
Detailed description:
- When we add above dependency and trying try building query using QueryBuilders.wrapperQuery(query) I get error saying
java.lang.NoSuchFieldError: LUCENE_8_8_2
at org.opensearch.Version.(Version.java:74)
at org.opensearch.core.common.io.stream.StreamOutput.(StreamOutput.java:107) - Hence explicitly specified the LUCENE version like below to 8_8_2 but I get same above error all the way till I increase the version to 9.1.0
org.apache.lucene
lucene-core
8.8.2
- Once moving to LUCENE_9_1_1 we get java.lang.NoSuchFieldError: LUCENE_7_0_0 like below from elastic
org.apache.lucene error from elastic bean
Caused by: org.springframework.beans.factory.BeanCreationException: Error creating bean with name ‘elasticsearchTemplate’ defined in class path resource [org/springframework/boot/autoconfigure/data/elasticsearch/ElasticsearchDataConfiguration$RestClientConfiguration.class]: Bean instantiation via factory method failed; nested exception is org.springframework.beans.BeanInstantiationException: Failed to instantiate [org.springframework.data.elasticsearch.core.ElasticsearchRestTemplate]: Factory method ‘elasticsearchTemplate’ threw exception; nested exception is java.lang.NoSuchFieldError: LUCENE_7_0_0 - When we remove elastic dependencies completely we get
org.springframework.beans.factory.BeanDefinitionStoreException: Failed to read candidate component class: file [/Users/develop/opensearch/spring-client/opensearch-test/target/classes/com/opensearchtest/indexing/doc/UsageDocument.class]; nested exception is java.lang.NoClassDefFoundError: org/elasticsearch/index/VersionType
Hence we were supposed to add the elastic dependency to our project.
org.elasticsearch.client
elasticsearch-rest-high-level-client
7.4.2
Please let me know in case anyone face similar issue or suggest me an alternative way to include spring-data-opensearch.