Skip to content

Commit

Permalink
Docs: Clarify constraints on scripted similarities. (#31076)
Browse files Browse the repository at this point in the history
Scripted similarities provide a lot of flexibility but they still need to obey
some rules to not confuse Lucene.
  • Loading branch information
jpountz authored Jun 5, 2018
1 parent c7c0acc commit f507381
Showing 1 changed file with 12 additions and 2 deletions.
14 changes: 12 additions & 2 deletions docs/reference/index-modules/similarity.asciidoc
Original file line number Diff line number Diff line change
Expand Up @@ -341,7 +341,18 @@ Which yields:
// TESTRESPONSE[s/"took": 12/"took" : $body.took/]
// TESTRESPONSE[s/OzrdjxNtQGaqs4DmioFw9A/$body.hits.hits.0._node/]

You might have noticed that a significant part of the script depends on
WARNING: While scripted similarities provide a lot of flexibility, there is
a set of rules that they need to satisfy. Failing to do so could make
Elasticsearch silently return wrong top hits or fail with internal errors at
search time:

- Returned scores must be positive.
- All other variables remaining equal, scores must not decrease when
`doc.freq` increases.
- All other variables remaining equal, scores must not increase when
`doc.length` increases.

You might have noticed that a significant part of the above script depends on
statistics that are the same for every document. It is possible to make the
above slightly more efficient by providing an `weight_script` which will
compute the document-independent part of the score and will be available
Expand Down Expand Up @@ -506,7 +517,6 @@ GET /index/_search?explain=true
////////////////////


Type name: `scripted`

[float]
Expand Down

0 comments on commit f507381

Please sign in to comment.