diff --git a/docs/reference/query-languages/query-dsl/query-dsl-function-score-query.md b/docs/reference/query-languages/query-dsl/query-dsl-function-score-query.md index b959568715406..3052c42ca6b0d 100644 --- a/docs/reference/query-languages/query-dsl/query-dsl-function-score-query.md +++ b/docs/reference/query-languages/query-dsl/query-dsl-function-score-query.md @@ -369,11 +369,16 @@ The `DECAY_FUNCTION` determines the shape of the decay: `gauss` : Normal decay, computed as: -![Gaussian](../images/Gaussian.png "") -where ![sigma](../images/sigma.png "") is computed to assure that the score takes the value `decay` at distance `scale` from `origin`+-`offset` +:::{math} +S(doc) = exp \left( - \dfrac{max(0, | fieldvalue_{doc} - origin| - offset)^2)}{ 2\sigma^2 } \right) +::: + +where $\sigma$ is computed to assure that the score takes the value `decay` at distance `scale` from `origin ± offset` -![sigma calc](../images/sigma_calc.png "") +:::{math} +\sigma^2 = -scale^2 / (2 \cdot ln(decay)) +::: See [Normal decay, keyword `gauss`](#gauss-decay) for graphs demonstrating the curve generated by the `gauss` function. @@ -381,11 +386,16 @@ See [Normal decay, keyword `gauss`](#gauss-decay) for graphs demonstrating the c `exp` : Exponential decay, computed as: -![Exponential](../images/Exponential.png "") -where again the parameter ![lambda](../images/lambda.png "") is computed to assure that the score takes the value `decay` at distance `scale` from `origin`+-`offset` +:::{math} +S(doc) = exp(\lambda \cdot max(0, |fieldvalue_{doc} - origin| - offset)) +::: -![lambda calc](../images/lambda_calc.png "") +where again the parameter $\lambda$ is computed to assure that the score takes the value `decay` at distance `scale` from `origin ± offset` + +:::{math} +\lambda = ln(decay)/scale +::: See [Exponential decay, keyword `exp`](#exp-decay) for graphs demonstrating the curve generated by the `exp` function. @@ -393,11 +403,16 @@ See [Exponential decay, keyword `exp`](#exp-decay) for graphs demonstrating the `linear` : Linear decay, computed as: -![Linear](../images/Linear.png ""). -where again the parameter `s` is computed to assure that the score takes the value `decay` at distance `scale` from `origin`+-`offset` +:::{math} +S(doc) = max \left( \dfrac{s - max(0, | fieldvalue_{doc} - origin| - offset)^2)}{ s }, 0 \right) +::: + +where again the parameter `s` is computed to assure that the score takes the value `decay` at distance `scale` from `origin ± offset` -![s calc](../images/s_calc.png "") +:::{math} +s = scale / (1.0 - decay) +::: In contrast to the normal and exponential decay, this function actually sets the score to 0 if the field value exceeds twice the user given scale value.