# Field value factor based on matched term

**URL:** <https://discuss.elastic.co/t/field-value-factor-based-on-matched-term/257241>\
**Category:** Elasticsearch\
**Created:** [December 1, 2020, 4:44pm UTC](https://discuss.elastic.co/t/field-value-factor-based-on-matched-term/257241 "2020-12-01T16:44:18Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Tianyi\_Mao](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/tianyi_mao/32/80037_2.png) [@Tianyi\_Mao](https://discuss.elastic.co/u/Tianyi_Mao)\
**Post date:** [December 1, 2020, 4:44pm UTC](https://discuss.elastic.co/t/field-value-factor-based-on-matched-term/257241/1 "2020-12-01T16:44:18Z")

</div>

In [https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-function-score-query.html#function-field-value-factor](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:

```auto
    {
    "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.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [December 29, 2020, 4:44pm UTC](https://discuss.elastic.co/t/field-value-factor-based-on-matched-term/257241/2 "2020-12-29T16:44:26Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
