Learning Elasticsearch
Abhishek Andhavarapu
- 404 pages
- English
- ePUB (mobile friendly)
- Available on iOS & Android
Learning Elasticsearch
Abhishek Andhavarapu
About This Book
Store, search, and analyze your data with ease using Elasticsearch 5.xAbout This Book• Get to grips with the basics of Elasticsearch concepts and its APIs, and use them to create efficient applications• Create large-scale Elasticsearch clusters and perform analytics using aggregation• This comprehensive guide will get you up and running with Elasticsearch 5.x in no timeWho This Book Is ForIf you want to build efficient search and analytics applications using Elasticsearch, this book is for you. It will also benefit developers who have worked with Lucene or Solr before and now want to work with Elasticsearch. No previous knowledge of Elasticsearch is expected.What You Will Learn• See how to set up and configure Elasticsearch and Kibana• Know how to ingest structured and unstructured data using Elasticsearch• Understand how a search engine works and the concepts of relevance and scoring• Find out how to query Elasticsearch with a high degree of performance and scalability• Improve the user experience by using autocomplete, geolocation queries, and much more• See how to slice and dice your data using Elasticsearch aggregations.• Grasp how to use Kibana to explore and visualize your data• Know how to host on Elastic Cloud and how to use the latest X-Pack features such as Graph and AlertingIn DetailElasticsearch is a modern, fast, distributed, scalable, fault tolerant, and open source search and analytics engine. You can use Elasticsearch for small or large applications with billions of documents. It is built to scale horizontally and can handle both structured and unstructured data. Packed with easy-to- follow examples, this book will ensure you will have a firm understanding of the basics of Elasticsearch and know how to utilize its capabilities efficiently.You will install and set up Elasticsearch and Kibana, and handle documents using the Distributed Document Store. You will see how to query, search, and index your data, and perform aggregation-based analytics with ease. You will see how to use Kibana to explore and visualize your data.Further on, you will learn to handle document relationships, work with geospatial data, and much more, with this easy-to-follow guide. Finally, you will see how you can set up and scale your Elasticsearch clusters in production environments.Style and approachThis comprehensive guide will get you started with Elasticsearch 5.x, so you build a solid understanding of the basics. Every topic is explained in depth and is supplemented with practical examples to enhance your understanding.
Frequently asked questions
Information
All About Search
- Structured queries
- Full-text queries
- Sort and pagination
- Relevance
- Routing
- Caching
Different types of queries
- Structured queries: Structured queries are used to query numbers, dates, statuses, and so on. These are similar to queries supported by a SQL database. For example, whether a number or date falls within a range or to find all the employees with John as the first name and so on
- Full-text search queries: Full-text search queries are used to search text fields. When you send a full-text query to Elasticsearch, it first finds all the documents that match the query, and then the documents are ranked based on how relevant each document is to the query. We will discuss relevance in detail in the Relevance section
Sample data
#Delete existing index if any
DELETE chapter6
#Mapping
PUT chapter6
{
"settings": {},
"mappings": {
"product": {
"properties": {
"product_name": {
"type": "text",
"analyzer": "english"
},
"description" : {
"type": "text",
"analyzer": "english"
}
}
}
}
}
#Index Documents
PUT chapter6/product/1
{
"product_name": "Men's High Performance Fleece Jacket",
"description": "Best Value. All season fleece jacket",
"unit_price": 79.99,
"reviews": 250,
"release_date": "2016-08-16"
}
PUT chapter6/product/2
{
"product_name": "Men's Water Resistant Jacket",
"description": "Provides comfort during biking and hiking",
"unit_price": 69.99,
"reviews": 5,
"release_date": "2017-03-02"
}
PUT chapter6/product/3
{
"product_name": "Women's wool Jacket",
"description": "Helps you stay warm in winter",
"unit_price": 59.99,
"reviews": 10,
"release_date": "2016-12-15"
}
Querying Elasticsearch
- By passing the search request as query parameters.
- By passing the search request in the request body.
GET chapter6/product/_search?q=product_name:jacket
POST chapter6/product/_search
{
"query": {
"term": {
"product_name" : "jacket"
}
}
}