Search icon CANCEL
Subscription
0
Cart icon
Your Cart (0 item)
Close icon
You have no products in your basket yet
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Free Learning
Arrow right icon
ElasticSearch Cookbook - Second Edition
ElasticSearch Cookbook - Second Edition

ElasticSearch Cookbook - Second Edition: Over 130 advanced recipes to search, analyze, deploy, manage, and monitor data effectively with ElasticSearch , Second Edition

Arrow left icon
Profile Icon Alberto Paro
Arrow right icon
$19.99 per month
Full star icon Full star icon Full star icon Full star icon Half star icon 4.1 (7 Ratings)
Paperback Jan 2015 472 pages 2nd Edition
eBook
$24.99 $36.99
Paperback
$60.99
Subscription
Free Trial
Renews at $19.99p/m
Arrow left icon
Profile Icon Alberto Paro
Arrow right icon
$19.99 per month
Full star icon Full star icon Full star icon Full star icon Half star icon 4.1 (7 Ratings)
Paperback Jan 2015 472 pages 2nd Edition
eBook
$24.99 $36.99
Paperback
$60.99
Subscription
Free Trial
Renews at $19.99p/m
eBook
$24.99 $36.99
Paperback
$60.99
Subscription
Free Trial
Renews at $19.99p/m

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing
Table of content icon View table of contents Preview book icon Preview Book

ElasticSearch Cookbook - Second Edition

Chapter 2. Downloading and Setting Up

In this chapter, we will cover the following topics:

  • Downloading and installing ElasticSearch
  • Setting up networking
  • Setting up a node
  • Setting up for Linux systems
  • Setting up different node types
  • Installing plugins in ElasticSearch
  • Installing a plugin manually
  • Removing a plugin
  • Changing logging settings

Introduction

This chapter explains how to install and configure ElasticSearch, from a single developer machine to a big cluster, giving you hints on how to improve performance and skip misconfiguration errors.

There are different options to install ElasticSearch and set up a working environment for development and production.

When testing out ElasticSearch for a development cluster, the configuration tool does not require any configurations to be set in it. However, when moving to production, it is important to properly configure the cluster based on your data and use cases. The setup step is very important because a bad configuration can lead to bad results and poor performances, and it can even kill your server.

In this chapter, the management of ElasticSearch plugins is also discussed: installing, configuring, updating, and removing.

Downloading and installing ElasticSearch

ElasticSearch has an active community and the release cycles are very fast.

Because ElasticSearch depends on many common Java libraries (Lucene, Guice, and Jackson are the most famous), the ElasticSearch community tries to keep them updated and fixes bugs that are discovered in them and the ElasticSearch core. The large user base is also a source of new ideas and features to improve ElasticSearch use cases.

For these reasons, if it's possible, best practice is to use the latest available release (usually, the most stable release and with the least bugs).

Getting ready

You need an ElasticSearch supported operating system (Linux / Mac OS X / Windows) with JVM 1.7 or above installed. A web browser is required to download the ElasticSearch binary release.

How to do it…

In order to download and install an ElasticSearch server, we will perform the following steps:

  1. Download ElasticSearch from the web. The latest version is always downloadable at http...

Setting up networking

Correctly setting up networking is very important for your nodes and cluster.

There are a lot of different installation scenarios and networking issues; we will cover two kinds of networking setups in this recipe:

  • A standard installation with an autodiscovery working configuration
  • A forced IP configuration, used if it is not possible to use autodiscovery

Getting ready

You need a working ElasticSearch installation, and you must know your current networking configuration (such as your IP addresses).

How to do it...

In order to configure networking, we will perform the following steps:

  1. With your favorite text editor application, open the ElasticSearch configuration file. Using the standard ElasticSearch configuration file (config/elasticsearch.yml), your node is configured to bind to all your machine interfaces and does an autodiscovery of the broadcasting events, which means that it sends signals to every machine in the current LAN and waits for a response. If a node responds...

Setting up a node

ElasticSearch allows you to customize several parameters in an installation. In this recipe, we'll see the most-used ones in order to define where to store data and improve performance in general.

Getting ready

You need a working ElasticSearch installation.

How to do it...

Perform the following steps to set up a simple node:

  1. Open the config/elasticsearch.yml file with an editor of your choice.
  2. Set up the directories that store your server data:
    • For Linux or Mac OS X:
      path.conf: /opt/data/es/conf
      path.data: /opt/data/es/data1,/opt2/data/data2
      path.work: /opt/data/work
      path.logs: /opt/data/logs
      path.plugins: /opt/data/plugins
    • For Windows:
      path.conf: c:\Elasticsearch\conf
      path.data: c:\Elasticsearch\data
      path.work: c:\Elasticsearch\work
      path.logs: c:\Elasticsearch\logs
      path.plugins: c:\Elasticsearch\plugins
  3. Set up parameters to control the standard index creation. These parameters are:
    index.number_of_shards: 5
    index.number_of_replicas: 1

How it works...

The path.conf parameter defines...

Setting up for Linux systems

If you are using a Linux system, you need to manage extra setup steps to improve performance or to resolve production problems with many indices.

This recipe covers two common errors that occur in production:

  • Too many open files, which can corrupt your indices and data
  • Slow performance when searching and indexing due to the garbage collector

    Note

    Other possible troubles arise when you run out of disk space. In this scenario, some files can get corrupted. To prevent your indices from corruption and possible data loss, a best practice is to monitor the storage space available.

Getting ready

You need a working ElasticSearch installation.

How to do it...

In order to improve performance on Linux systems, perform the following steps:

  1. First, you need to change the current limit of the users that runs the ElasticSearch server. In our examples, we will call it elasticsearch.
  2. To allow ElasticSearch to manage a large number of files, you need to increment the number of file descriptors...

Setting up different node types

ElasticSearch is natively designed for the Cloud, so when you need to release a production environment with a huge number of records, and you need high availability and good performances, you need to aggregate more nodes in a cluster.

ElasticSearch allows you to define different type of node to balance and improve overall performance.

Getting ready

You need a working ElasticSearch installation.

How to do it...

For the advanced setup of a cluster, there are some parameters that must be configured to define different node types.

These parameters are in config/elasticsearch.yml and can be set by performing these steps:

  1. Set up whether or not the node can be a master node:
    node.master: true
  2. Set up whether or not a node must contain data:
    node.data: true

How it works...

The node.master parameter defines whether the node can become a master for the Cloud. The default value for this parameter is true.

A master node is an arbiter for the Cloud: it takes decisions about shard...

Introduction


This chapter explains how to install and configure ElasticSearch, from a single developer machine to a big cluster, giving you hints on how to improve performance and skip misconfiguration errors.

There are different options to install ElasticSearch and set up a working environment for development and production.

When testing out ElasticSearch for a development cluster, the configuration tool does not require any configurations to be set in it. However, when moving to production, it is important to properly configure the cluster based on your data and use cases. The setup step is very important because a bad configuration can lead to bad results and poor performances, and it can even kill your server.

In this chapter, the management of ElasticSearch plugins is also discussed: installing, configuring, updating, and removing.

Downloading and installing ElasticSearch


ElasticSearch has an active community and the release cycles are very fast.

Because ElasticSearch depends on many common Java libraries (Lucene, Guice, and Jackson are the most famous), the ElasticSearch community tries to keep them updated and fixes bugs that are discovered in them and the ElasticSearch core. The large user base is also a source of new ideas and features to improve ElasticSearch use cases.

For these reasons, if it's possible, best practice is to use the latest available release (usually, the most stable release and with the least bugs).

Getting ready

You need an ElasticSearch supported operating system (Linux / Mac OS X / Windows) with JVM 1.7 or above installed. A web browser is required to download the ElasticSearch binary release.

How to do it…

In order to download and install an ElasticSearch server, we will perform the following steps:

  1. Download ElasticSearch from the web. The latest version is always downloadable at http://www.elasticsearch...

Setting up networking


Correctly setting up networking is very important for your nodes and cluster.

There are a lot of different installation scenarios and networking issues; we will cover two kinds of networking setups in this recipe:

  • A standard installation with an autodiscovery working configuration

  • A forced IP configuration, used if it is not possible to use autodiscovery

Getting ready

You need a working ElasticSearch installation, and you must know your current networking configuration (such as your IP addresses).

How to do it...

In order to configure networking, we will perform the following steps:

  1. With your favorite text editor application, open the ElasticSearch configuration file. Using the standard ElasticSearch configuration file (config/elasticsearch.yml), your node is configured to bind to all your machine interfaces and does an autodiscovery of the broadcasting events, which means that it sends signals to every machine in the current LAN and waits for a response. If a node responds...

Setting up a node


ElasticSearch allows you to customize several parameters in an installation. In this recipe, we'll see the most-used ones in order to define where to store data and improve performance in general.

Getting ready

You need a working ElasticSearch installation.

How to do it...

Perform the following steps to set up a simple node:

  1. Open the config/elasticsearch.yml file with an editor of your choice.

  2. Set up the directories that store your server data:

    • For Linux or Mac OS X:

      path.conf: /opt/data/es/conf
      path.data: /opt/data/es/data1,/opt2/data/data2
      path.work: /opt/data/work
      path.logs: /opt/data/logs
      path.plugins: /opt/data/plugins
    • For Windows:

      path.conf: c:\Elasticsearch\conf
      path.data: c:\Elasticsearch\data
      path.work: c:\Elasticsearch\work
      path.logs: c:\Elasticsearch\logs
      path.plugins: c:\Elasticsearch\plugins
  3. Set up parameters to control the standard index creation. These parameters are:

    index.number_of_shards: 5
    index.number_of_replicas: 1

How it works...

The path.conf parameter defines...

Left arrow icon Right arrow icon

Description

If you are a developer who implements ElasticSearch in your web applications and want to sharpen your understanding of the core elements and applications, this is the book for you. It is assumed that you’ve got working knowledge of JSON and, if you want to extend ElasticSearch, of Java and related technologies.

What you will learn

  • Make ElasticSearch work for you by choosing the best cloud topology and powering it with plugins
  • Develop tailored mapping to take full control of index steps
  • Build complex queries through managing indices and documents
  • Optimize search results through executing analytics aggregations
  • Manage rivers (SQL, NoSQL, and webbased) to synchronize and populate crosssource data
  • Develop web interfaces to execute key tasks
  • Monitor the performance of the cluster and nodes

Product Details

Country selected
Publication date, Length, Edition, Language, ISBN-13
Publication date : Jan 28, 2015
Length: 472 pages
Edition : 2nd
Language : English
ISBN-13 : 9781783554836
Vendor :
Elastic
Category :
Languages :

What do you get with a Packt Subscription?

Free for first 7 days. $19.99 p/m after that. Cancel any time!
Product feature icon Unlimited ad-free access to the largest independent learning library in tech. Access this title and thousands more!
Product feature icon 50+ new titles added per month, including many first-to-market concepts and exclusive early access to books as they are being written.
Product feature icon Innovative learning tools, including AI book assistants, code context explainers, and text-to-speech.
Product feature icon Thousands of reference materials covering every tech concept you need to stay up to date.
Subscribe now
View plans & pricing

Product Details

Publication date : Jan 28, 2015
Length: 472 pages
Edition : 2nd
Language : English
ISBN-13 : 9781783554836
Vendor :
Elastic
Category :
Languages :

Packt Subscriptions

See our plans and pricing
Modal Close icon
$19.99 billed monthly
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Simple pricing, no contract
$199.99 billed annually
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just $5 each
Feature tick icon Exclusive print discounts
$279.99 billed in 18 months
Feature tick icon Unlimited access to Packt's library of 7,000+ practical books and videos
Feature tick icon Constantly refreshed with 50+ new titles a month
Feature tick icon Exclusive Early access to books as they're written
Feature tick icon Solve problems while you work with advanced search and reference features
Feature tick icon Offline reading on the mobile app
Feature tick icon Choose a DRM-free eBook or Video every month to keep
Feature tick icon PLUS own as many other DRM-free eBooks or Videos as you like for just $5 each
Feature tick icon Exclusive print discounts

Frequently bought together


Stars icon
Total $ 176.97
Elasticsearch Server: Second Edition
$54.99
Mastering Elasticsearch - Second Edition
$60.99
ElasticSearch Cookbook - Second Edition
$60.99
Total $ 176.97 Stars icon
Banner background image

Table of Contents

13 Chapters
1. Getting Started Chevron down icon Chevron up icon
2. Downloading and Setting Up Chevron down icon Chevron up icon
3. Managing Mapping Chevron down icon Chevron up icon
4. Basic Operations Chevron down icon Chevron up icon
5. Search, Queries, and Filters Chevron down icon Chevron up icon
6. Aggregations Chevron down icon Chevron up icon
7. Scripting Chevron down icon Chevron up icon
8. Rivers Chevron down icon Chevron up icon
9. Cluster and Node Monitoring Chevron down icon Chevron up icon
10. Java Integration Chevron down icon Chevron up icon
11. Python Integration Chevron down icon Chevron up icon
12. Plugin Development Chevron down icon Chevron up icon
Index Chevron down icon Chevron up icon

Customer reviews

Top Reviews
Rating distribution
Full star icon Full star icon Full star icon Full star icon Half star icon 4.1
(7 Ratings)
5 star 42.9%
4 star 28.6%
3 star 28.6%
2 star 0%
1 star 0%
Filter icon Filter
Top Reviews

Filter reviews by




LSR Nov 19, 2015
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Got on time and met my expectations.
Amazon Verified review Amazon
Jan Borgelin Mar 16, 2015
Full star icon Full star icon Full star icon Full star icon Full star icon 5
While cookbooks are not a suitable format for every technology out there, it certainly works for ElasticSearch, as it has so many features to write about.The book covers everything from setting up and configuring a single server or a cluster, working with the REST API (along with good recommendations on plugins to make your life more comfortable) as well as short examples in Python and Java to get you comfortable transforming your knowledge in REST interface to programming languages.Recipes represent common tasks you will encounter while working with ES, thus it serves as a good reference book after you've finished reading it.The 2nd edition of the book is updated for ElasticSearch v.1.4.x, the chapter on aggregations is worth the price tag alone.I highly recommend this book to anyone who needs to quickly master ElasticSearch and is having problems in finding his way through the official documentation.
Amazon Verified review Amazon
A. S. May 05, 2015
Full star icon Full star icon Full star icon Full star icon Full star icon 5
Prior to this book, my ElasticSearch knowledge had been cobbled together by updating existing queries, reading a few blog posts, and a healthy amount of documentation skimming. This book seemed promising, especially as a desk-side reference. What I got was so much more.Unlike most of the "cookbooks" I've read, it opens with a well-paced introduction to ElasticSearch, spending a little time focusing on internals (e.g. routing) so that when they're fully discussed in later chapters, readers will already be conversant in some of the concepts. This was the ES tutorial I needed.Then, once it gets into the advanced application portions, it pays off again. ElasticSearch has gained new features over the past few years. Due to their newness, the available documentation (beyond what Elastic provides) is fairly sparse. The ElasticSearch cookbook does a good job of nailing those parts down, especially the chapters on aggregations and scripting.Overall, I'd recommend this book for anyone developing with (or on) ElasticSearch. It's an invaluable resource.
Amazon Verified review Amazon
Wouter Blancquaert Mar 23, 2015
Full star icon Full star icon Full star icon Full star icon Empty star icon 4
Unlike ‘Mastering ElasticSearch’, which is mostly a complete reference to the product, this book introduces a hands-on introduction to ElasticSearch. This book is not a pageturner, but to understand everything that’s inside, it should be read with a computer nearby. The contents of every chapter is divided in a more or less repeating fashion with following sections: ‘Getting ready’, ‘How to do it’, ‘How it works'; making it easy to read and understand. Accompanied with lots of code samples, you should gain enough insights to use ElasticSearch as a product for as well personal as professional use.
Amazon Verified review Amazon
Michal Domanski Mar 27, 2015
Full star icon Full star icon Full star icon Full star icon Empty star icon 4
Recommended reading for everyone using or planning to use ElasticSearch. This book combines a hands on approach with a broad spectrum of ElasticSearch features discussed. I'm a heavy user of ElasticSearch and I wish I've read this book earlier.
Amazon Verified review Amazon
Get free access to Packt library with over 7500+ books and video courses for 7 days!
Start Free Trial

FAQs

What is included in a Packt subscription? Chevron down icon Chevron up icon

A subscription provides you with full access to view all Packt and licnesed content online, this includes exclusive access to Early Access titles. Depending on the tier chosen you can also earn credits and discounts to use for owning content

How can I cancel my subscription? Chevron down icon Chevron up icon

To cancel your subscription with us simply go to the account page - found in the top right of the page or at https://subscription.packtpub.com/my-account/subscription - From here you will see the ‘cancel subscription’ button in the grey box with your subscription information in.

What are credits? Chevron down icon Chevron up icon

Credits can be earned from reading 40 section of any title within the payment cycle - a month starting from the day of subscription payment. You also earn a Credit every month if you subscribe to our annual or 18 month plans. Credits can be used to buy books DRM free, the same way that you would pay for a book. Your credits can be found in the subscription homepage - subscription.packtpub.com - clicking on ‘the my’ library dropdown and selecting ‘credits’.

What happens if an Early Access Course is cancelled? Chevron down icon Chevron up icon

Projects are rarely cancelled, but sometimes it's unavoidable. If an Early Access course is cancelled or excessively delayed, you can exchange your purchase for another course. For further details, please contact us here.

Where can I send feedback about an Early Access title? Chevron down icon Chevron up icon

If you have any feedback about the product you're reading, or Early Access in general, then please fill out a contact form here and we'll make sure the feedback gets to the right team. 

Can I download the code files for Early Access titles? Chevron down icon Chevron up icon

We try to ensure that all books in Early Access have code available to use, download, and fork on GitHub. This helps us be more agile in the development of the book, and helps keep the often changing code base of new versions and new technologies as up to date as possible. Unfortunately, however, there will be rare cases when it is not possible for us to have downloadable code samples available until publication.

When we publish the book, the code files will also be available to download from the Packt website.

How accurate is the publication date? Chevron down icon Chevron up icon

The publication date is as accurate as we can be at any point in the project. Unfortunately, delays can happen. Often those delays are out of our control, such as changes to the technology code base or delays in the tech release. We do our best to give you an accurate estimate of the publication date at any given time, and as more chapters are delivered, the more accurate the delivery date will become.

How will I know when new chapters are ready? Chevron down icon Chevron up icon

We'll let you know every time there has been an update to a course that you've bought in Early Access. You'll get an email to let you know there has been a new chapter, or a change to a previous chapter. The new chapters are automatically added to your account, so you can also check back there any time you're ready and download or read them online.

I am a Packt subscriber, do I get Early Access? Chevron down icon Chevron up icon

Yes, all Early Access content is fully available through your subscription. You will need to have a paid for or active trial subscription in order to access all titles.

How is Early Access delivered? Chevron down icon Chevron up icon

Early Access is currently only available as a PDF or through our online reader. As we make changes or add new chapters, the files in your Packt account will be updated so you can download them again or view them online immediately.

How do I buy Early Access content? Chevron down icon Chevron up icon

Early Access is a way of us getting our content to you quicker, but the method of buying the Early Access course is still the same. Just find the course you want to buy, go through the check-out steps, and you’ll get a confirmation email from us with information and a link to the relevant Early Access courses.

What is Early Access? Chevron down icon Chevron up icon

Keeping up to date with the latest technology is difficult; new versions, new frameworks, new techniques. This feature gives you a head-start to our content, as it's being created. With Early Access you'll receive each chapter as it's written, and get regular updates throughout the product's development, as well as the final course as soon as it's ready.We created Early Access as a means of giving you the information you need, as soon as it's available. As we go through the process of developing a course, 99% of it can be ready but we can't publish until that last 1% falls in to place. Early Access helps to unlock the potential of our content early, to help you start your learning when you need it most. You not only get access to every chapter as it's delivered, edited, and updated, but you'll also get the finalized, DRM-free product to download in any format you want when it's published. As a member of Packt, you'll also be eligible for our exclusive offers, including a free course every day, and discounts on new and popular titles.