B.2. Installing plugins

In order to use a plugin, you first need to install it. Plugins come in many forms, but they’re most frequently .zip files. You can choose to manually extract a .zip file to the plugins directory, or you can use the bin/plugin tool to install it by downloading it either from the internet or from a local zip file.

You’ll start by installing the elasticsearch-head plugin, as shown in the following listing. You can find the plugin here: https://mobz.github.io/elasticsearch-head/. You’ll install it using the built-in plugin shell script that comes with Elasticsearch. On Windows, you can use the plugin.bat script to install plugins.

Listing B.1. Installing the elasticsearch-head plugin

Here you can see that the plugin script has downloaded the plugin from github.com and installed the elasticsearch-head plugin into the plugins/head directory. It also has detected that the plugin is a site plugin.

You can list plugins that have been installed by using the -l or --list parameters to the plugin script, as shown in the next listing.

Listing B.2. Listing installed plugins

$ bin/plugin --list

Installed plugins:

  • head

In this case, you install a site plugin that was automatically downloaded from GitHub, but there are also other ways to install plugins. Running the bin/plugin script without any parameters shows you all of the options available. See the next listing.

Listing B.3. Available options of the plugin script

$ bin/plugin Usage:

-u, --url [plugin location] : Set exact URL to download the plugin from

-i, --install [plugin name] : Downloads and installs listed plugins [*]

-t, --timeout [duration] : Timeout setting: 30s, 1m, 1h... (infinite by default)

-r, --remove [plugin name] : Removes listed plugins

-l, --list : List installed plugins

-v, --verbose : Prints verbose messages

-s, --silent : Run in silent mode

-h, --help : Prints this help message

[*] Plugin name could be: elasticsearch/plugin/version for official elasticsearch plugins (download from download.elasticsearch.org)

groupId/artifactId/version for community plugins (download from maven central or oss sonatype) username/repository for site plugins (download from github master)

Here you can see at the bottom of the output the three different kinds of plugins that can be automatically downloaded—from Elasticsearch, from Maven Central, or directly from GitHub. You can also specify the URL manually, as shown in listing B.4, using the --url parameter, which allows you to install from a local file as well.

For example, if you had a plugin downloaded locally that you wanted to install, you could install it by prepending file:/// to the full path of the ZIP file. But if you do this, you’ll need to manually specify the name of the plugin you’re installing.

Listing B.4. Manually installing a plugin from a local ZIP file

$ bin/plugin --url file:///downloads/elasticsearch-head.zip --install head -> Installing head...

Trying file:/downloads/elasticsearch-head.zip...

Downloading .........DONE

Installed head into /Users/hinmanm/ies/elasticsearch-1.5.1/plugins/head Identified as a _site plugin, moving to _site structure ...

Now that you’ve installed the plugin by either having the plugin tool download the plugin or installing from a local file, you’ll want to be able to access the plugin from Elasticsearch.