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 to add new analyzers. Typically, you need to create an analyzer plugin when you need to do the following:
- Adding standard Lucene analyzers/tokenizers, which are not provided by ElasticSearch
- Integrating third party analyzers
- Adding a custom analyzer
In this recipe, we will add a new custom English analyzer similar to the one provided by ElasticSearch.
Getting ready
You will need a working ElasticSearch node, a Maven build tool, and optionally a Java IDE. The code of this recipe is available in the chapter12/analysis_plugin
directory.
How to do it...
An analyzer plugin is generally composed of the following three classes:
- A plugin class that registers the
BinderProcessor
class - A
BinderProcessor
class that registers one or moreAnalyzerProviders
class - An
AnalyzerProviders
class that provides an analyzer plugin...