Whip up recipes with 'Elasticsearch 8.x Cookbook'

Elasticsearch is a powerful and potentially complicated tool. With 'Elasticsearch 8.x Cookbook,' users can split exercises into manageable bites.

Software engineers, developers and just about everyone else must be prepared to keep pace as technology evolves.

While right now that means working with and in the cloud, the future might lie in virtual reality or serverless technology. However, there is at least one constant: data -- lots of data. To manage this data, software developers, engineers and architects can rely on tools to parse and display information. One such tool is Elasticsearch, a search and analytics engine.

Why choose Elasticsearch?

Elasticsearch offers its users many benefits, such as REST-based APIs, schema-free JSON documents, the ability to process large volumes of data in parallel, and integrations with plugins and tools, such as Kibana, Beats and Logstash.

Before users can reach these benefits, they must overcome a steep learning curve. To help with that, Elasticsearch 8.x Cookbook, Fifth Edition, provides readers with recipes to perform searches and other tasks.

For those unfamiliar with what a recipe is -- at least when it comes to Elasticsearch -- recipe is the technical name for the way the web is calling services, explained Alberto Paro, an engineer, manager and software developer at Accenture Italia, and the author of Elasticsearch 8.x Cookbook, Fifth Edition.

With Elasticsearch, engineers can accomplish many tasks, across many fields, by using its search and analytics capabilities. "I use these kinds of capabilities in different markets, to track car mobility and trips, to healthcare, to be able to search in huge amounts of data," Paro said. "... Every day I have some new challenge using these kinds of tools."

Elasticsearch 8.x Cookbook cover Click to learn more about
'Elasticsearch 8.x Cookbook.'

This book covers 18 different tasks -- including mapping, scripting, managing clusters, plugin development and big data integration -- broken down into smaller steps.

For example, this excerpt from Chapter 16 explains how to create a plugin.

Generally, Elasticsearch plugins are developed in Java using the Gradle build tool (https://gradle.org/) and deployed as a ZIP file.

To create a simple JAR plugin, we will perform the following steps:

  1. To correctly build and serve a plugin, some files must be defined:
    • build.gradle and settings.gradle are used to define the build configuration for Gradle.
    • LICENSE.txt defines the plugin license.
    • NOTICE.txt is a copyright notice.
  2. A build.gradle file is used to create a plugin that contains the following code:
    buildscript { 
      repositories { 
        mavenCentral() 
      } 
      dependencies { 
        classpath "org.elasticsearch.gradle:build-tools:8.0.0" 
      } 
    } 
    repositories { 
      mavenCentral() 
    } 
    group = 'org.elasticsearch.plugin' 
    version = '8.0.0-SNAPSHOT' 
    apply plugin: 'java' 
    apply plugin: 'idea' 
    apply plugin: 'elasticsearch.esplugin' 
    apply plugin: 'elasticsearch.yaml-rest-test' 
    esplugin { 
      name 'simple-plugin' 
      description 'A simple plugin for ElasticSearch' 
      classname 'org.elasticsearch.plugin.simple.SimplePlugin' 
      // license of the plugin, may be different than the above license 
      licenseFile rootProject.file('LICENSE.txt') 
      // copyright notices, may be different than the above notice 
      noticeFile rootProject.file('NOTICE.txt') 
    } 
    // In this section you declare the dependencies for your production and test code 
    // Note, the two dependencies are not really needed as the buildscript dependency gets them in already 
    // they are just here as an example 
    dependencies { 
      implementation 'org.elasticsearch:elasticsearch:8.0.0' 
      yamlRestTestImplementation 'org.elasticsearch.test:framework:8.0.0' 
    } 
    // ignore javadoc linting errors for now 
    tasks.withType(Javadoc) { 
      options.addStringOption('Xdoclint:none', '-quiet') 
    }
  3. The settings.gradle file is used for the project name, as follows:
    rootProject.name = 'simple-plugin'
  4. The src/main/java/org/elasticsearch/plugin/simple/SimplePlugin.java class is an example of the basic (the minimum required) code that needs to be compiled for executing a plugin, as follows:
    package org.elasticsearch.plugin.simple;
    import org.elasticsearch.plugins.Plugin;
    public class SimplePlugin extends Plugin {
    }

From here, the chapter breaks down in individual sections how this plugin works and what is required to create a good lifecycle for a plugin.

Alberto Paro, technology architecture delivery associate director, Accenture ItaliaAlberto Paro

"Plugins give you [the] ability to extend Elasticsearch with everything you want," Paro said. He added that, for example, users can create a plugin to manage machine learning activities. "Elasticsearch is not a monolithic application, but is a tool that can grow with your business needs, and plugin development is one of the main points that gives you the ability to extend Elasticsearch."

Editor's note: This chapter excerpt is from Elasticsearch 8.x Cookbook, Fifth Edition, authored by Alberto Paro, publishing with Packt Publishing, May 27, 2022, ISBN: 9781801079815. To read Chapter 16 of the book in its entirety, click here.

Dig Deeper on IT systems management and monitoring

Software Quality
App Architecture
Cloud Computing
SearchAWS
TheServerSide.com
Data Center
Close