In https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-function-score-query.html#function-field-value-factor
it is mentioned that one can use a numeric field in the document to influence scoring. Can it work with scripted similarity to affect the score there?
Example:
say if we have two documents:
{
"field":"foo bar baz",
"foo": 2.0,
"bar": 3.0
}
{
"field":"foo how good",
"foo": 10.0,
"good": 5.0
}
I wish the similarity scores to be further boosted by values of the matched term. For example, if we search "foo bar"
, the score will be doc['foo']*(score of foo) + doc['bar']*(score of bar)
.
For 1st document it will look like 2.0*(score of foo) + 3.0*(score of bar)
.
For 2nd document it will look like 10.0*(score of foo)
. bar
is not matched here so the second term is omitted.
If one searches "foo good"
, the score will be doc['foo']*(score of foo) + doc['good']*(score of good)
. Similarly, the term good
will not show up and will not play any part in scoring of the 1st document.