Skip to content

Commit 967c0cb

Browse files
authored
Decay docs changes using math directive (#137369)
1 parent 7cb2bd5 commit 967c0cb

File tree

6 files changed

+24
-9
lines changed

6 files changed

+24
-9
lines changed
-1.74 KB
Binary file not shown.
-2.22 KB
Binary file not shown.
-2.18 KB
Binary file not shown.
-928 Bytes
Binary file not shown.
-1.69 KB
Binary file not shown.

docs/reference/query-languages/query-dsl/query-dsl-function-score-query.md

Lines changed: 24 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -369,35 +369,50 @@ The `DECAY_FUNCTION` determines the shape of the decay:
369369
`gauss`
370370
: Normal decay, computed as:
371371

372-
![Gaussian](../images/Gaussian.png "")
373372

374-
where ![sigma](../images/sigma.png "") is computed to assure that the score takes the value `decay` at distance `scale` from `origin`+-`offset`
373+
:::{math}
374+
S(doc) = exp \left( - \dfrac{max(0, | fieldvalue_{doc} - origin| - offset)^2}{ 2\sigma^2 } \right)
375+
:::
376+
377+
where ![sigma](../images/sigma.png "") is computed to assure that the score takes the value `decay` at distance `scale` from `origin ± offset`
375378

376-
![sigma calc](../images/sigma_calc.png "")
379+
:::{math}
380+
\sigma^2 = -scale^2 / (2 \cdot ln(decay))
381+
:::
377382

378383
See [Normal decay, keyword `gauss`](#gauss-decay) for graphs demonstrating the curve generated by the `gauss` function.
379384

380385

381386
`exp`
382387
: Exponential decay, computed as:
383388

384-
![Exponential](../images/Exponential.png "")
385389

386-
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`
390+
:::{math}
391+
S(doc) = exp(\lambda \cdot max(0, |fieldvalue_{doc} - origin| - offset))
392+
:::
387393

388-
![lambda calc](../images/lambda_calc.png "")
394+
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`
395+
396+
:::{math}
397+
\lambda = ln(decay)/scale
398+
:::
389399

390400
See [Exponential decay, keyword `exp`](#exp-decay) for graphs demonstrating the curve generated by the `exp` function.
391401

392402

393403
`linear`
394404
: Linear decay, computed as:
395405

396-
![Linear](../images/Linear.png "").
397406

398-
where again the parameter `s` is computed to assure that the score takes the value `decay` at distance `scale` from `origin`+-`offset`
407+
:::{math}
408+
S(doc) = max \left( \dfrac{s - max(0, | fieldvalue_{doc} - origin| - offset)}{ s }, 0 \right)
409+
:::
410+
411+
where again the parameter `s` is computed to assure that the score takes the value `decay` at distance `scale` from `origin ± offset`
399412

400-
![s calc](../images/s_calc.png "")
413+
:::{math}
414+
s = scale / (1.0 - decay)
415+
:::
401416

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

0 commit comments

Comments
 (0)