Search icon
Arrow left icon
All Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Newsletters
Free Learning
Arrow right icon
Learning Elasticsearch

You're reading from  Learning Elasticsearch

Product type Book
Published in Jun 2017
Publisher Packt
ISBN-13 9781787128453
Pages 404 pages
Edition 1st Edition
Languages
Author (1):
Abhishek Andhavarapu Abhishek Andhavarapu
Profile icon Abhishek Andhavarapu

Table of Contents (11) Chapters

Preface Introduction to Elasticsearch Setting Up Elasticsearch and Kibana Modeling Your Data and Document Relations Indexing and Updating Your Data Organizing Your Data and Bulk Data Ingestion All About Search More Than a Search Engine (Geofilters, Autocomplete, and More) How to Slice and Dice Your Data Using Aggregations Production and Beyond Exploring Elastic Stack (Elastic Cloud, Security, Graph, and Alerting)

Setting Up Elasticsearch and Kibana

In this chapter, we will discuss how to set up Elasticsearch and Kibana. We will first install Elasticsearch as a single-node cluster and then install Kibana. Running Elasticsearch is very easy as it can be started without any configuration; it is designed to run out of the box. Once we have Elasticsearch up and running, we will go through various APIs that are available to gauge the health of the cluster. By the end of this chapter, we will have covered the following:

  • Installing Elasticsearch
  • Installing Kibana
  • Kibana Dev Tools
  • HTTP clients
  • Monitoring cluster health

Installing Elasticsearch

In this section, we will install Elasticsearch on a local machine as a single-node cluster. Once we have the cluster up and running, we will learn how to use cluster APIs to check the health of the nodes. We have a Windows section for Windows users, a Mac OS X section for Mac users, and a Debian/RPM section for users who want to install using the Debian (deb)/RPM package.

If you are a Linux/Unix user, you can either install using the Debian/RPM package or you can follow instructions in the Mac OS X section.

Installing Java

Elasticsearch is a Java-based application. Before we can run Elasticsearch, we need to make sure that we have Java installed. You need a Java Runtime Environment(JRE). Elasticsearch...

Installing Kibana

In this section, we will install Kibana. Kibana is a web interface to visualize and analyze the data in Elasticsearch. Kibana also provides developer tools, which is very handy for running Elasticsearch queries. The queries used in the book can be executed using Kibana developer tools. You need Elasticsearch up and running before you can start using Kibana. Make sure the Kibana version matches the Elasticsearch version. At the time of writing, the latest Elasticsearch version is 5.1.2.

Mac OS X

You can download Kibana for Mac OS X from the following Elasticsearch website:

curl -L -O https://artifacts.elastic.co/downloads/kibana/kibana-5.1.2-darwin-x86_64.tar.gz
tar -xvf kibana-5.1.2-darwin-x86_64.tar.gz

Once...

Query format used in this book (Kibana Console)

The query format used in this book is based on Kibana Console. When using other HTTP clients such as cURL or Postman, the Elasticsearch endpoint (like http://127.0.0.1:900) should be passed in the URL, when using Kibana Console it is automatically inferred from Kibana settings. Using Kibana Console while in development or for debugging is strongly recommended. You can access Kibana Console by going to Dev Tools tab in the navigation bar on the left.

The Kibana Console look like the following:

Kibana Console has a very simple UI and is divided into request and response windows. The request window makes it very easy to work with JSON requests and supports auto-completion and auto indentation. The response window makes it very easy to follow the JSON response as you can expand or minimize parts of the JSON response. You can also copy...

Using cURL or Postman

The primary way of interacting with Elasticsearch is using the REST API over HTTP. If Kibana or Sense is not an option for you, you can use any of the popular HTTP clients, such as cURL or Postman. Curl is a command line-based client available on most operating systems. Postman is an UI-based HTTP client available for major operating systems. You can get postman from the following link:

https://www.getpostman.com/

To execute the queries in this book using other HTTP clients, you have to specify the Elasticsearch server address (such as http://127.0.0.1:9200) in front of the API endpoint to execute the query. Let's take an example query found in this book:

 POST es-index/_search
{
"query": {
"match_all": {}
}
}

To execute the preceding query in cURL, you should add the curl command and the -d flag and wrap the query in...

Health of the cluster

Elasticsearch provides various APIs for operational management of clusters and nodes. One of the important APIs is cluster API. In the previous section, we started a single-node cluster. We can check the health of the cluster using the cluster API as follows:

http://127.0.0.1:9200/_cluster/health?pretty

The pretty flag at the end of the URL makes the JSON response more readable. The response from the cluster API is shown next:

{
"cluster_name": "es-dev",
"status": "green",
"timed_out": false,
"number_of_nodes": 1,
"number_of_data_nodes": 1,
"active_primary_shards": 0,
"active_shards": 0,
"relocating_shards": 0,
"initializing_shards": 0,
"unassigned_shards": 0,
"delayed_unassigned_shards": 0,
"number_of_pending_tasks...

Summary

In this chapter, we learned how to install and configure Elasticsearch. We also learned how to install Kibana. We discussed the various HTTP clients we can use to talk to Elasticsearch. A lot of examples have been used throughout the book to better explain various concepts. With Elasticsearch and Kibana up and running, you can now try out the queries in the examples.

In the next chapter, we will talk about how to model data and manage relations in Elasticsearch.

lock icon The rest of the chapter is locked
You have been reading a chapter from
Learning Elasticsearch
Published in: Jun 2017 Publisher: Packt ISBN-13: 9781787128453
Register for a free Packt account to unlock a world of extra content!
A free Packt account unlocks extra newsletters, articles, discounted offers, and much more. Start advancing your knowledge today.
Unlock this book and the full library FREE for 7 days
Get unlimited access to 7000+ expert-authored eBooks and videos courses covering every tech area you can think of
Renews at $15.99/month. Cancel anytime}