Creating an analyzer plugin
Elasticsearch provides, out-of-the-box, a large set of analyzers and tokenizers to cover general needs. Sometimes we need to extend the capabilities of Elasticsearch by adding new analyzers.
Typically you can create an analyzer plugin when you need:
To add standard Lucene analyzers/tokenizers not provided by Elasticsearch
To integrate third-part analyzers
To add custom analyzers
In this recipe we will add a new custom English analyzer similar to the one provided by Elasticsearch.
Getting ready
You need an up-and-running Elasticsearch installation as we described in the Downloading and installing Elasticsearch recipe in Chapter 2, Downloading and Setup.
A Maven tool, or an IDE that supports Java programming, such as Eclipse or IntelliJ IDEA. The code for this recipe is available in the chapter17/analysis_plugin
directory.
How to do it...
An analyzer plugin is generally composed of two classes:
A
Plugin
class, which implements theorg.elasticsearch.plugins.AnalysisPlugin
class...