From 57a734e641d9bfdff7e8dbae535e577db20e7db3 Mon Sep 17 00:00:00 2001 From: Britta Weber Date: Thu, 30 Jun 2016 11:52:53 +0200 Subject: [PATCH] [doc] explain avg in function_score better (#19154) * [doc] explain avg in function_score better --- docs/reference/query-dsl/function-score-query.asciidoc | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/docs/reference/query-dsl/function-score-query.asciidoc b/docs/reference/query-dsl/function-score-query.asciidoc index b6e4dedbc88..c6477b78d8b 100644 --- a/docs/reference/query-dsl/function-score-query.asciidoc +++ b/docs/reference/query-dsl/function-score-query.asciidoc @@ -83,9 +83,16 @@ First, each document is scored by the defined functions. The parameter `max`:: maximum score is used `min`:: minimum score is used -Because scores can be on different scales (for example, between 0 and 1 for decay functions but arbitrary for `field_value_factor`) and also because sometimes a different impact of functions on the score is desirable, the score of each function can be adjusted with a user defined `weight` (). The `weight` can be defined per function in the `functions` array (example above) and is multiplied with the score computed by the respective function. +Because scores can be on different scales (for example, between 0 and 1 for decay functions but arbitrary for `field_value_factor`) and also +because sometimes a different impact of functions on the score is desirable, the score of each function can be adjusted with a user defined +`weight`. The `weight` can be defined per function in the `functions` array (example above) and is multiplied with the score computed by +the respective function. If weight is given without any other function declaration, `weight` acts as a function that simply returns the `weight`. +In case `score_mode` is set to `avg` the individual scores will be combined by a **weighted** average. +For example, if two functions return score 1 and 2 and their respective weights are 3 and 4, then their scores will be combined as +`(1*3+2*4)/(3+4)` and **not** `(1*3+2*4)/2`. + The new score can be restricted to not exceed a certain limit by setting the `max_boost` parameter. The default for `max_boost` is FLT_MAX.