Built-in functions under the function score query
The following are the built-in functions available to be used with the function_score
query:
The
weight
functionThe
field_value_factor
functionThe
script_score
functionDecay functions -
linear
,exp
,gauss
Let's look at them one by one.
The weight function
The weight
function allows you to apply a simple boost to each document without the boost being normalized: a weight
of 2
results in 2 * _score
. For example:
curl -XGET "http://localhost:9200/library/_search" -d' { "query": { "function_score": { "query": { "match": { "tags": "novel" } }, "functions": [ { "filter": { "term": { "tags": "classics" } }, "weight": 2 } ], "boost_mode": "replace" } } }'
The preceding query will match all the books which belong to the novel
category, but will give a higher score to books that also...