How to include TransportClient 5.3.2 without Lucene dependencies?

Hi all,
I'm trying to include the Java Transport Client in my webapp for enriching its searching functionalities by Elasticsearch integration.
I have installed Elasticsearch version 5.3.2 on my laptop and I have added the following dependency in the pom of my webapp:

<dependency>
   <groupId>org.elasticsearch.client</groupId>
   <artifactId>transport</artifactId>
   <version>5.3.2</version>
</dependency>

The issues is that the transport client depends on Lucene (version 6.4.2) and in my webapp we already embed Lucene (version 3.6.0) which cannot be upgraded.

I have tried to exclude Lucene dependencies but then I get errors (due to Lucene classes not found) when I try to instatiate the client:
Settings settings = Settings.builder().put("cluster.name", "mycluster")
.put("client.transport.sniff", true).build();
TransportClient client = new PreBuiltTransportClient(settings)
.addTransportAddress(new InetSocketTransportAddress(InetAddress.getByName("localhost"), 9300));
List clusterDiscoveredNodes = client.connectedNodes();

My question is: since we're a speaking of a "transport" client, why we need to included also Lucene?
Is there a way of using the transport client without including Lucene dependencies?

If not, the best solution is to use the lighter rest client?

Best regards,
Pietro

My question is: since we’re a speaking of a “transport” client, why we need to included also Lucene?

This is historical. The TransportClient has been there since the beginning and queries depends on Lucene classes.

Is there a way of using the transport client without including Lucene dependencies?

Not out of the box.
You can may be try to shade some libs as explained in To shade or not to shade | Elastic Blog

If not, the best solution is to use the lighter rest client?

Yes. But note that the high level one which is coming soon will also depend on elasticsearch core project for now. So you will be able to use only the low level one.

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