Search icon CANCEL
Arrow left icon
Explore Products
Best Sellers
New Releases
Books
Videos
Audiobooks
Learning Hub
Conferences
Free Learning
Arrow right icon
Arrow up icon
GO TO TOP
Mastering Elasticsearch 5.x

You're reading from   Mastering Elasticsearch 5.x Master the intricacies of Elasticsearch 5 and use it to create flexible and scalable search solutions

Arrow left icon
Product type Paperback
Published in Feb 2017
Publisher Packt
ISBN-13 9781786460189
Length 428 pages
Edition 3rd Edition
Languages
Arrow right icon
Author (1):
Arrow left icon
Bharvi Dixit Bharvi Dixit
Author Profile Icon Bharvi Dixit
Bharvi Dixit
Arrow right icon
View More author details
Toc

Table of Contents (13) Chapters Close

Preface 1. Revisiting Elasticsearch and the Changes FREE CHAPTER 2. The Improved Query DSL 3. Beyond Full Text Search 4. Data Modeling and Analytics 5. Improving the User Search Experience 6. The Index Distribution Architecture 7. Low-Level Index Control 8. Elasticsearch Administration 9. Data Transformation and Federated Search 10. Improving Performance 11. Developing Elasticsearch Plugins 12. Introducing Elastic Stack 5.0

Controlling scores using the function score query


In most cases, you are good to go with the default scoring algorithms of Elasticsearch to return the most relevant results. However, some cases require you to have more control over the calculation of a score. This is especially required while implementing domain-specific logics where you need to implement a very specific scoring formula and alter the final score. Elasticsearch provides you with the function_score query to take control of all these things.

The function_score query allows you to take complete control of how a score needs to be calculated for a particular query. The syntax of the function_score query is given as follows:

{ 
  "query": {"function_score": { 
    "query": {}, 
    "boost": "boost for the whole query", 
    "functions": [ 
      {} 
    ], 
    "max_boost": number, 
    "score_mode": "(multiply|max|...)", 
    "boost_mode": "(multiply|replace|...)", 
    "min_score" : number 
  }} 
} 

The function_score query has...

lock icon The rest of the chapter is locked
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 $19.99/month. Cancel anytime