Prepare recipes with ‘Elasticsearch 8.x Cookbook’

0

Software engineers, developers, and just about everyone else need to be prepared to keep pace with changing technology.

While currently that means working with and in the cloud, the future could 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 analyze and display the information. One such tool is Elasticsearch, a search and analytics engine.

Why Choose Elasticsearch?

Elasticsearch offers its users many advantages, 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 achieve these benefits, they must overcome a steep learning curve. To help with this, Elasticsearch 8.x Cookbookfifth edition, provides readers with recipes for performing research and other tasks.

For those who don’t know what a recipe is — at least as far as Elasticsearch is concerned — Recipe is the technical name for how the web calls services, explains Alberto Paro, engineer, manager and software developer at Accenture Italia, and author of Elasticsearch 8.x CookbookFifth edition.

With Elasticsearch, engineers can accomplish many tasks, in many fields, using its search and analysis capabilities. “I use these kinds of capabilities in different markets, to track mobility and car travel, for healthcare, to be able to search through massive amounts of data,” Paro said. “…Every day I have a new challenge using these kinds of tools.”

Click to learn more about

‘Elasticsearch 8.x cookbook.’

This book covers 18 different tasks – including mapping, scripting, cluster management, plugin development, and big data integration – broken down into smaller steps.

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

Typically, 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 properly build and serve a plugin, some files need to be defined:
    • build.gradle and settings.gradle are used to set the build configuration for Gradle.
    • LICENSE.txt defines the license of the plugin.
    • NOTICE.txt is a copyright notice.
  2. A build.gradle 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 code (the minimum required) that must be compiled to run a plugin, as follows:
    package org.elasticsearch.plugin.simple;
    import org.elasticsearch.plugins.Plugin;
    public class SimplePlugin extends Plugin {
    }

From there, the chapter breaks down into individual sections how this plugin works and what is needed to create a good lifecycle for a plugin.

Alberto Paro, Associate Director of Technology Architecture Delivery, Accenture ItaliaAlberto Paro

“Plugins give you [the] ability to extend Elasticsearch with anything 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 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 Cookbookfifth edition, authored by Alberto Paro, edition with Packt Publishing, May 27, 2022, ISBN: 9781801079815. To read chapter 16 of the book in its entirety, click here.

Share.

Comments are closed.