Book Image

ElasticSearch Cookbook

By : Alberto Paro
Book Image

ElasticSearch Cookbook

By: Alberto Paro

Overview of this book

Table of Contents (20 chapters)
ElasticSearch Cookbook Second Edition
Credits
About the Author
Acknowledgments
About the Reviewers
www.PacktPub.com
Preface
Index

Creating a river plugin


In Chapter 8, Rivers, we saw how powerful the river plugins are. They allow you to populate an ElasticSearch cluster from different sources (DBMS, NoSQL system, streams, and so on). Creating a custom river is necessary if you need to do the following:

  • Add a new NoSQL data source that is not supported by the already existing plugins

  • Add a new stream type

  • Add a custom business logic to import data in ElasticSearch, such as field modification, data aggregation, and, in general, a data brewery

In this recipe, we will implement a simple river that generates documents with a field that contains an incremental value and ingests them in 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/river_plugin directory.

How to do it...

To create a river plugin, we need the following three classes at least:

  • The plugin that registers a river module

  • A river module that registers...