ElasticSearch plugins

In various places in this book we have used ElasticSearch plugins. You probably remember the additional programming languages used in scripts or rivers and their support for attachments to documents. Let's see how plugins work and how to install them.

ElasticSearch plugins are located in their own subdirectory in the plugins directory. If you downloaded a new plugin from a site, you can just create a new directory with the plugin name and unpack that plugin archive to that directory. There is also a more convenient way to install plugins—by using the plugin script. We have used it several times in this book so this is the time to describe this tool.

Installing plugins

By default, plugins are fetched from the download.elasticsearch.org site. If the plugin is not available in this location, Maven Central (http://search.maven.org/) and Maven Sonatype (https://repository.sonatype.org/) repositories are checked. The plugin tool assumes that the given plugin address contains the organization's name followed by the plugin name and version number. Look at the following example:

bin/plugin -install elasticsearch/elasticsearch-lang-javascript/1.1.0

We want to install an additional language for scripting functionality. We chose version 1.1.0 of this plugin. We can also omit version number, that is, in this case ElasticSearch will try to find a version that equals the version of ElasticSearch or the latest (master) version. This is an example result of this command:

-> Installing elasticsearch/elasticsearch-lang-javascript/1.1.0...
Trying http://download.elasticsearch.org/elasticsearch/elasticsearch-lang-javascript/elasticsearch-lang-javascript-1.1.0.zip...
Downloading ...........................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................................DONE
Installed lang-javascript

If you write your own plugin and have no access to the previously mentioned sites, there is no problem. The plugin tool also provides a –url option that allows us to set any location for plugins including the local filesystem (using the file:// prefix).

Removing plugins

Removing a plugin just means removing its directory. You can also do this using the plugin tool; for example:

bin/plugin -remove river-mongodb
-> Removing river-mongodb

Plugin types

ElasticSearch has two main types of plugins based on their contents: Java plugins and site plugins. ElasticSearch treats site plugins as a file set that should be served by a built-in HTTP server under the /_plugin/plugin_name/ URL (for example, /_plugin/bigdesk/). In addition to that, every plugin without Java content is automatically treated as a site plugin. That's all. From ElasticSearch's point of view, a site plugin doesn't change anything in the ElasticSearch behavior.

Java plugins usually contain JAR files that are scanned for the es-plugin.properties file. This file contains information about the main class that should be used by ElasticSearch as an entry point to configure plugins and allow them to extend the ElasticSearch functionality. The Java plugins can contain a site part that will be used by the built-in HTTP server (just like with the site plugins). This part of the plugin needs to be placed in the _site directory.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset