Book Image

Mastering Elasticsearch 5.x - Third Edition

By : Bharvi Dixit
Book Image

Mastering Elasticsearch 5.x - Third Edition

By: Bharvi Dixit

Overview of this book

Elasticsearch is a modern, fast, distributed, scalable, fault tolerant, and open source search and analytics engine. Elasticsearch leverages the capabilities of Apache Lucene, and provides a new level of control over how you can index and search even huge sets of data. This book will give you a brief recap of the basics and also introduce you to the new features of Elasticsearch 5. We will guide you through the intermediate and advanced functionalities of Elasticsearch, such as querying, indexing, searching, and modifying data. We’ll also explore advanced concepts, including aggregation, index control, sharding, replication, and clustering. We’ll show you the modules of monitoring and administration available in Elasticsearch, and will also cover backup and recovery. You will get an understanding of how you can scale your Elasticsearch cluster to contextualize it and improve its performance. We’ll also show you how you can create your own analysis plugin in Elasticsearch. By the end of the book, you will have all the knowledge necessary to master Elasticsearch and put it to efficient use.
Table of Contents (13 chapters)

Multimatch types


In this section, we will cover the different flavors of multi-match queries, which are mainly controlled using the type property. The following are the available types:

  • The best_fields type

  • The most_fields type

  • The cross_fields type

  • The phrase type

  • The phrase_prefix type

Best fields matching

To use the best_fields type matching, one needs to set the type property of the multi_match query to the best_fields query. This type of multimatching will generate a match query for each field specified in the fields property and it is best used for searching for multiple words in the same best matching field. For example, let's look at the following query:

curl -XGET 'localhost:9200/library/_search?pretty' -d '{ 
  "query" : { 
    "multi_match" : { 
      "query" : "complete conan doyle", 
      "fields" : [ "title", "author", "characters" ], 
      "type" : "best_fields", 
      "tie_breaker" : 0.8 
    } 
  } 
}'

The preceding query would be translated into a query similar to the following...