Deploy Elasticsearch Rest Client into OSGi
Reading time1 Minutes
Up until Elasticsearch 5.0.0 alpha 4 the official Elasticsearch Java client required the complete Elasticsearch distributable included in your application. Although there are several alternative clients available, the new Java Rest Client brings most of the functionallity bundled in a small package.
Since the artifact published by elastic does not contain the required OSGi bundle information I created a wrapper you can find on Github1.
All dependencies are inherited from the RestClient and available as OSGi Bundles:
If you deploy the bundle into an AEM instance (>=6.1), you only have to install the httpasyncclient2 (version 4.0.2 should be fine).
I have not published the wrapper into Maven Central yet, therefor you have to checkout the Repository manually and then install the Bundle using Maven.
mvn clean install sling:install -Dsling.url=http://localhost:4502/system/console
You can now use the dependency in your projects.
<dependency> <groupId>de.dev.eth0.elasticsearch</groupId> <artifactId>elasticsearch-rest-osgi</artifactId> <version>5.1.1-SNAPSHOT</version> </dependency>