I am trying to use ElasticSearch from Java using the high level API, as per this tutorial:
https://www.baeldung.com/elasticsearch-java
but the compiler is unable to locate most of the classes of the API.
As instructed, I have included this in my pom.xml
<dependency>
<groupId>org.elasticsearch</groupId
<artifactId>elasticsearch</artifactId>
<version>7.6.2</version>
</dependency>
And when I do a mvn build, it does download elasticsearch-7.6.2.jar to my maven repo.
But this jar does not seem to include many of the classes mentioned in the Baeldung tutorial.
In particular, it does not include the ClientConfiguration class. The command below
jar tvf elasticsearch-7.6.2.jar | grep ClientConfiguration
yields nothing.
Note that I have tried with a more recent version of ES (7.17.7) and likewise, it does not contain the ClientConfiguration class.
So, which dependency do I have to add in order to get those classes?
Thx.
CodePudding user response:
I recommend read Getting started documentarion:
If you work Java low level rest client.
If you work Java API Client.
CodePudding user response:
Three things.
First, follow the official ES documentation as suggested by rabbitbr.
BUT...
Don't use the latest version of elasticsearch-java because there there does not seem to be a maven artifact for that one. So instead, include the latest stable version. In my case, that was:
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>elasticsearch-java</artifactId>
<version>8.5.2</version>
</dependency>
Finally, make sure you also include the dependency for the elasticsearch-rest-client. This was mentioned at the end of the doc, but should really be mentioned in the installation section of the doc:
<dependency>
<groupId>org.elasticsearch.client</groupId>
<artifactId>elasticsearch-rest-client</artifactId>
<version>8.5.2</version>
</dependency>