O'Reilly logo

Mastering Elasticsearch 5.x - Third Edition by Bharvi Dixit

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required