Issues when using Opensearch & Elasticsearch rest high level clients - Any Lucene compatible version? Other solutions?

Versions (relevant - OpenSearch/Dashboard/Server OS/Browser):
Opensearch rest high level client version = 2.5.0
Elasticsearch rest high level client version = 7.17.1

Describe the issue:
Hi!

I am working with a maven java based project using Elasticsearch + Opensearch. As stated in the Versions info above, we are using both high level rest clients loaded with maven. We have used these together for a long time now (around 1 year if I recall). We have users using both the Elasticsearch part of the project and the Opensearch part.

I know today that these clients are deprecated and we most likely will start updating the tool in the future.

We are still using these versions until a new tool / big update to new java clients arrive.
Recently we have noted that when we get an exception (OpensearchException or any of its subclasses) that we get an “NoSuchFieldError: LUCENE_9_1_0

Looking at the java stacktrace leads us to the “org.opensearch.Version” class which have a bunch of “public static final Version” fields with a bunch of org.apache.lucene.util.Version.LUCENE_X_Y_Z.

Due to Lucene library conflicts from Opensearch and Elasticsearch only some of the “org.apache.lucene.util.Version.LUCENE_X_Y_Z” versions are available which in turn raised the NoSuchFieldError when the Opensearch.Version is read and used (i assume) since some of the static fields doesn’t actually “exist” due to dependency conflict.

What we have done:
We have tried to exclude the lucene-core dependency from one of the libraries but in the end we can’t find a “lucene.core” version that contains compatible “org.apache.lucene.util.Version,LUCENE_X_Y_Z” fields for both libraries.

Also checked if upgrading one or both of the libraries would help with lucene dependency issues to no luck since Opensearch library uses a lot newer lucene that Elasticsearch lib.

Currently we get the lucene dependecy from Elasticsearch so Elasticsearch get all its needed versions etc. If we would swap to exclude Elasticsearch lucene dependency instead, we would get the same issue for Elasticsearch (but Opensearch would work ) since they work pretty much the same when when it comes to the ElasticsearchException / OpensearchException.

So, as long as the OpensearchExecption class is not called we have no issues but once an OpensearchException occurs this issue arise.

My Question: Long story made short. Does anyone know any compatible versions between these two rest high level clients or any other solution to make both libraries (ES + OS) work together? Any one else using these to rest high level clients together?

Sorry for long description of background :slight_smile:

Configuration:

Relevant Logs or Screenshots:
image

Hey @Johol ,

Long story made short. Does anyone know any compatible versions between these two rest
high level clients or any other solution to make both libraries (ES + OS) work together? Any one
else using these to rest high level clients together?

Your best option here (if you really need to stay on rest high level clients) is to use the versions of OS/ES clients that depend on the same Apache Lucene major versions. Alternatively, the more risky approach is to exclude all transifive Apache Lucene dependencies from ES client (since OS always bundle more recent ones). That may work at compile time but blow up at runtime …

This topic was automatically closed 60 days after the last reply. New replies are no longer allowed.