Skip to content

Latest commit

 

History

History
90 lines (59 loc) · 3.4 KB

README.md

File metadata and controls

90 lines (59 loc) · 3.4 KB

Dropwizard Elasticsearch

Build Status Coverage Status

A set of classes for using [Elasticsearch] 1 in a [Dropwizard] 2 application.

The package provides a [lifecycle-managed] 3 client class (ManagedEsClient), a configuration class with the most common options (EsConfiguration), and some [health checks] 4 which can instantly be used in any Dropwizard application.

Usage

Just add EsConfiguration to your Configuration class and create an ManagedEsClient instance in the run method of your service.

You can also add one of the existing health checks to your Environment in the same method. At least the usage of EsClusterHealthCheck is strongly advised.

public class DemoApplication extends Application<DemoConfiguration> {
    // [...]
    @Override
    public void run(DemoConfiguration config, Environment environment) {
        final ManagedEsClient managedClient = new ManagedEsClient(configuration.getEsConfiguration());
        environment.lifecycle().manage(managedClient);
        environment.healthChecks().register("ES cluster health", new EsClusterHealthCheck(managedClient.getClient()));
        // [...]
    }
}

Configuration

The following configuration settings are supported by EsConfiguration:

  • nodeClient: When true, ManagedEsClient will create a NodeClient, otherwise a TransportClient; default: true
  • servers: A list of servers for usage with the created TransportClient if nodeClient is false
  • clusterName: The name of the Elasticsearch cluster; default: "elasticsearch"
  • settings: Any additional settings for Elasticsearch, see Configuration

An example configuration file for creating a Node Client could like this:

clusterName: MyClusterName
settings:
  node.name: MyCustomNodeName

Maven Artifacts

This project is available on Maven Central. To add it to your project simply add the following dependencies to your pom.xml:

<dependency>
  <groupId>io.dropwizard.modules</groupId>
  <artifactId>dropwizard-elasticsearch</artifactId>
  <version>0.7.0-1</version>
</dependency>

Support

Please file bug reports and feature requests in GitHub issues.

Acknowledgements

Thanks to Alexander Reelsen (@spinscale) for his Dropwizard Blog Sample which sparked the idea for this project.

License

Copyright (c) 2013-2014 Jochen Schalanda

This library is licensed under the Apache License, Version 2.0.

See http://www.apache.org/licenses/LICENSE-2.0.html or the LICENSE file in this repository for the full license text.