Book Image

Elasticsearch Indexing

By : Huseyin Akdogan
Book Image

Elasticsearch Indexing

By: Huseyin Akdogan

Overview of this book

Beginning with an overview of the way ElasticSearch stores data, you’ll begin to extend your knowledge to tackle indexing and mapping, and learn how to configure ElasticSearch to meet your users’ needs. You’ll then find out how to use analysis and analyzers for greater intelligence in how you organize and pull up search results – to guarantee that every search query is met with the relevant results! You’ll explore the anatomy of an ElasticSearch cluster, and learn how to set up configurations that give you optimum availability as well as scalability. Once you’ve learned how these elements work, you’ll find real-world solutions to help you improve indexing performance, as well as tips and guidance on safety so you can back up and restore data. Once you’ve learned each component outlined throughout, you will be confident that you can help to deliver an improved search experience – exactly what modern users demand and expect.
Table of Contents (15 chapters)
Elasticsearch Indexing
About the Author
About the Reviewer


The world that we live in is hungry for speed, efficiency, and accuracy. We want quick results and faster without compromising the accuracy. This is exactly why I have written this book. I have penned down my years of experience in this book to give you an insight into how to use Elasticsearch more efficiently in today's big data world. This book is targeted at experienced developers who have used Elasticsearch before and want to extend their knowledge about how to effectively perform Elasticsearch indexing. While reading this book, you'll explore different topics, all of which connect to efficient indexing and relevant search results in Elasticsearch. We will focus on understanding the document storage strategy and analysis process in Elasticsearch. This book will help you understand what is going on behind the scenes when you send a document for indexing or make a query. In addition, this book will ensure correct understanding of the meaning of schemaless by asking the question—is the claim that Elasticsearch stands for the schema-free model always true? After this, you will learn the analysis process and about analyzers. More importantly, this book will elaborate the relationship between data analysis and relevant search results. By the end of this book, I believe you will be in a position to master and unleash this beast of a technology.

What this book covers

Chapter 1, Introduction to Efficient Indexing, will introduce you to the document storage strategy and the basic concepts related to the analysis process.

Chapter 2, What is an Elasticsearch Index, describes the concept of Elasticsearch Index, how the inverted index mechanism works, why you should use data denormalization, and what its benefits. In addition to this, it explains dynamic mapping and index flexibility.

Chapter 3, Basic Concepts of Mapping, describes the basic concepts and definitions of mapping. It answers the question what is the relationship between mapping and relevant search results questions. It explains the meaning of schemaless. It also covers metadata fields and data types.

Chapter 4, Analysis and Analyzers, describes analyzers and the analysis process of Elasticsearch, what tokenizers, the character and token filters, how to configure a custom analyzer and what text normalization is. This chapter also describes the relationship between data analysis and relevant search results.

Chapter 5, Anatomy of an Elasticsearch Cluster, covers techniques to choose the right number of shards and replicas and describes a node, the shard concept, replicas, and how shard allocation works. It also explains the architecture of data distribution.

Chapter 6, Improving Indexing Performance, covers how to configure memory, how JVM garbage collector works, why garbage collector is so important for performance, and how to start tuning garbage collector. It also describes how to control the amount of I/O operations that Elasticsearch uses for segment merging and to store modules.

Chapter 7, Snapshot and Restore, covers the Elasticsearch snapshot and restore module, how to define a snapshot repository, different repository types, the process of snapshot and restore, and how to configure them. It also describes how the snapshot process works.

Chapter 8, Improving the User Search Experience, introduces Elasticsearch suggesters, which allow us to correct spelling mistakes and build efficient autocomplete mechanisms. It also covers how to improve query relevance by using different Elasticsearch functionalities such as boosting and synonyms.

What you need for this book

You need a stable version of Elasticsearch. The code of the book is compatible with Elasticsearch version 1 and later. You can examine the code of the book using cURL (that is, Client URL Library) on Linux and MacOS X. Plus, if you need a user-friendly query interface, you can use the sense plugin running on Chrome (

Who this book is for

If you understand the importance of a great search experience, this book will show you exactly how to build one with Elasticsearch—one of the world's leading search servers.


In this book, you will find a number of text styles that distinguish between different kinds of information. Here are some examples of these styles and an explanation of their meaning.

Code words in text, database table names, folder names, filenames, file extensions, pathnames, dummy URLs, user input, and Twitter handles are shown as follows: "We can include other contexts through the use of the include directive."

A block of code is set as follows:

curl -XPOST localhost:9200/company/employee -d '{
  "firstname": "Joe Jeffers",
  "lastname": "Hoffman",
  "age": 30

Any command-line input or output is written as follows:

curl -XGET 'localhost:9200/_cat/health?pretty'
1448644024 19:07:04 elasticsearch yellow 1 1 6 6 0 0 6 0

New terms and important words are shown in bold. Words that you see on the screen, for example, in menus or dialog boxes, appear in the text like this: "Elasticsearch allows us to use the Suggest API functionality."


Warnings or important notes appear in a box like this.


Tips and tricks appear like this.

Reader feedback

Feedback from our readers is always welcome. Let us know what you think about this book—what you liked or disliked. Reader feedback is important for us as it helps us develop titles that you will really get the most out of.

To send us general feedback, simply e-mail , and mention the book's title in the subject of your message.

If there is a topic that you have expertise in and you are interested in either writing or contributing to a book, see our author guide at

Customer support

Now that you are the proud owner of a Packt book, we have a number of things to help you to get the most from your purchase.

Downloading the example code

You can download the example code files from your account at for all the Packt Publishing books you have purchased. If you purchased this book elsewhere, you can visit and register to have the files e-mailed directly to you.


Although we have taken every care to ensure the accuracy of our content, mistakes do happen. If you find a mistake in one of our books—maybe a mistake in the text or the code—we would be grateful if you could report this to us. By doing so, you can save other readers from frustration and help us improve subsequent versions of this book. If you find any errata, please report them by visiting, selecting your book, clicking on the Errata Submission Form link, and entering the details of your errata. Once your errata are verified, your submission will be accepted and the errata will be uploaded to our website or added to any list of existing errata under the Errata section of that title.

To view the previously submitted errata, go to and enter the name of the book in the search field. The required information will appear under the Errata section.


Piracy of copyrighted material on the Internet is an ongoing problem across all media. At Packt, we take the protection of our copyright and licenses very seriously. If you come across any illegal copies of our works in any form on the Internet, please provide us with the location address or website name immediately so that we can pursue a remedy.

Please contact us at with a link to the suspected pirated material.

We appreciate your help in protecting our authors and our ability to bring you valuable content.


If you have a problem with any aspect of this book, you can contact us at , and we will do our best to address the problem.