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

eBook
€24.99 €36.99
Paperback
€45.99
Subscription
Free Trial
Renews at €18.99p/m

What do you get with Print?

Product feature icon Instant access to your digital eBook copy whilst your Print order is Shipped
Product feature icon Paperback book shipped to your preferred address
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Shipping Address

Billing Address

Shipping Methods
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
Estimated delivery fee Deliver to Italy

Premium delivery 7 - 10 business days

€17.95
(Includes tracking information)

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 Print?

Product feature icon Instant access to your digital eBook copy whilst your Print order is Shipped
Product feature icon Paperback book shipped to your preferred address
Product feature icon Download this book in EPUB and PDF formats
Product feature icon Access this title in our online reader with advanced features
Product feature icon DRM FREE - Read whenever, wherever and however you want
OR
Modal Close icon
Payment Processing...
tick Completed

Shipping Address

Billing Address

Shipping Methods
Estimated delivery fee Deliver to Italy

Premium delivery 7 - 10 business days

€17.95
(Includes tracking information)

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
€18.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
€189.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
€264.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 133.97
Elasticsearch Server: Second Edition
€41.99
Mastering Elasticsearch - Second Edition
€45.99
ElasticSearch Cookbook - Second Edition
€45.99
Total 133.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 the delivery time and cost of print book? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela
What is custom duty/charge? Chevron down icon Chevron up icon

Customs duty are charges levied on goods when they cross international borders. It is a tax that is imposed on imported goods. These duties are charged by special authorities and bodies created by local governments and are meant to protect local industries, economies, and businesses.

Do I have to pay customs charges for the print book order? Chevron down icon Chevron up icon

The orders shipped to the countries that are listed under EU27 will not bear custom charges. They are paid by Packt as part of the order.

List of EU27 countries: www.gov.uk/eu-eea:

A custom duty or localized taxes may be applicable on the shipment and would be charged by the recipient country outside of the EU27 which should be paid by the customer and these duties are not included in the shipping charges been charged on the order.

How do I know my custom duty charges? Chevron down icon Chevron up icon

The amount of duty payable varies greatly depending on the imported goods, the country of origin and several other factors like the total invoice amount or dimensions like weight, and other such criteria applicable in your country.

For example:

  • If you live in Mexico, and the declared value of your ordered items is over $ 50, for you to receive a package, you will have to pay additional import tax of 19% which will be $ 9.50 to the courier service.
  • Whereas if you live in Turkey, and the declared value of your ordered items is over € 22, for you to receive a package, you will have to pay additional import tax of 18% which will be € 3.96 to the courier service.
How can I cancel my order? Chevron down icon Chevron up icon

Cancellation Policy for Published Printed Books:

You can cancel any order within 1 hour of placing the order. Simply contact [email protected] with your order details or payment transaction id. If your order has already started the shipment process, we will do our best to stop it. However, if it is already on the way to you then when you receive it, you can contact us at [email protected] using the returns and refund process.

Please understand that Packt Publishing cannot provide refunds or cancel any order except for the cases described in our Return Policy (i.e. Packt Publishing agrees to replace your printed book because it arrives damaged or material defect in book), Packt Publishing will not accept returns.

What is your returns and refunds policy? Chevron down icon Chevron up icon

Return Policy:

We want you to be happy with your purchase from Packtpub.com. We will not hassle you with returning print books to us. If the print book you receive from us is incorrect, damaged, doesn't work or is unacceptably late, please contact Customer Relations Team on [email protected] with the order number and issue details as explained below:

  1. If you ordered (eBook, Video or Print Book) incorrectly or accidentally, please contact Customer Relations Team on [email protected] within one hour of placing the order and we will replace/refund you the item cost.
  2. Sadly, if your eBook or Video file is faulty or a fault occurs during the eBook or Video being made available to you, i.e. during download then you should contact Customer Relations Team within 14 days of purchase on [email protected] who will be able to resolve this issue for you.
  3. You will have a choice of replacement or refund of the problem items.(damaged, defective or incorrect)
  4. Once Customer Care Team confirms that you will be refunded, you should receive the refund within 10 to 12 working days.
  5. If you are only requesting a refund of one book from a multiple order, then we will refund you the appropriate single item.
  6. Where the items were shipped under a free shipping offer, there will be no shipping costs to refund.

On the off chance your printed book arrives damaged, with book material defect, contact our Customer Relation Team on [email protected] within 14 days of receipt of the book with appropriate evidence of damage and we will work with you to secure a replacement copy, if necessary. Please note that each printed book you order from us is individually made by Packt's professional book-printing partner which is on a print-on-demand basis.

What tax is charged? Chevron down icon Chevron up icon

Currently, no tax is charged on the purchase of any print book (subject to change based on the laws and regulations). A localized VAT fee is charged only to our European and UK customers on eBooks, Video and subscriptions that they buy. GST is charged to Indian customers for eBooks and video purchases.

What payment methods can I use? Chevron down icon Chevron up icon

You can pay with the following card types:

  1. Visa Debit
  2. Visa Credit
  3. MasterCard
  4. PayPal
What is the delivery time and cost of print books? Chevron down icon Chevron up icon

Shipping Details

USA:

'

Economy: Delivery to most addresses in the US within 10-15 business days

Premium: Trackable Delivery to most addresses in the US within 3-8 business days

UK:

Economy: Delivery to most addresses in the U.K. within 7-9 business days.
Shipments are not trackable

Premium: Trackable delivery to most addresses in the U.K. within 3-4 business days!
Add one extra business day for deliveries to Northern Ireland and Scottish Highlands and islands

EU:

Premium: Trackable delivery to most EU destinations within 4-9 business days.

Australia:

Economy: Can deliver to P. O. Boxes and private residences.
Trackable service with delivery to addresses in Australia only.
Delivery time ranges from 7-9 business days for VIC and 8-10 business days for Interstate metro
Delivery time is up to 15 business days for remote areas of WA, NT & QLD.

Premium: Delivery to addresses in Australia only
Trackable delivery to most P. O. Boxes and private residences in Australia within 4-5 days based on the distance to a destination following dispatch.

India:

Premium: Delivery to most Indian addresses within 5-6 business days

Rest of the World:

Premium: Countries in the American continent: Trackable delivery to most countries within 4-7 business days

Asia:

Premium: Delivery to most Asian addresses within 5-9 business days

Disclaimer:
All orders received before 5 PM U.K time would start printing from the next business day. So the estimated delivery times start from the next day as well. Orders received after 5 PM U.K time (in our internal systems) on a business day or anytime on the weekend will begin printing the second to next business day. For example, an order placed at 11 AM today will begin printing tomorrow, whereas an order placed at 9 PM tonight will begin printing the day after tomorrow.


Unfortunately, due to several restrictions, we are unable to ship to the following countries:

  1. Afghanistan
  2. American Samoa
  3. Belarus
  4. Brunei Darussalam
  5. Central African Republic
  6. The Democratic Republic of Congo
  7. Eritrea
  8. Guinea-bissau
  9. Iran
  10. Lebanon
  11. Libiya Arab Jamahriya
  12. Somalia
  13. Sudan
  14. Russian Federation
  15. Syrian Arab Republic
  16. Ukraine
  17. Venezuela