Can I safely use Solr and Elasticsearch dependencies in the same Java project?

Intro
Hi so I have a Java project which started as a way to get data from a database and transport it into Solr. This project uses Maven and relies on the solr-core and solr-solrj artifacts as dependencies. For the Solr dependencies it uses version 6.6.2 of those libraries. Now I am trying to expand this app to also write data into Elasticsearch. I am using the elasticsearch, elasticsearch-rest-high-level-client, and elasticsearch-rest-client all on version 7.6.0

I ran into issues where my unit tests weren't working because of an error
java.lang.NoClassDefFoundError: org/apache/lucene/document/LegacyIntField

This was due to a lucene-core conflict under the elasticsearch dependency. ES was using lucene-core version 8.4.0 and Solr was using 6.6.2. I excluded lucene-core from elasticsearch and now my unit tests work and my data seems to be flowing fine as well but now I can't publish with ES. Need to figure out how to have Solr and ElasticSearch use their own lucene-core libraries if that is even possible. I have been trying to shade by following https://github.com/elastic/elasticsearch/issues/29184#issuecomment-475052904 but I have not found much luck.

Question
How can I allow ES and Solr to play nicely and use their own Lucene versions? Cheers!

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