Deploy Elasticsearch Rest Client into OSGi

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.

Dependencies

All dependencies are inherited from the RestClient and available as OSGi Bundles:

  • org.apache.httpcomponents:httpasyncclient
  • org.apache.httpcomponents:httpcore-nio
  • org.apache.httpcomponents:httpclient
  • org.apache.httpcomponents:httpcore
  • commons-codec:commons-codec
  • commons-logging:commons-logging

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).

Installation

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

Usage

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>

Footnotes

Related Posts