# Boost value depending on number of common terms

**URL:** <https://discuss.elastic.co/t/boost-value-depending-on-number-of-common-terms/315267>\
**Category:** Elasticsearch\
**Created:** [September 27, 2022, 2:05pm UTC](https://discuss.elastic.co/t/boost-value-depending-on-number-of-common-terms/315267 "2022-09-27T14:05:10Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![pzmudzinski](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/pzmudzinski/32/111345_2.png) [@pzmudzinski](https://discuss.elastic.co/u/pzmudzinski)\
**Post date:** [September 27, 2022, 2:05pm UTC](https://discuss.elastic.co/t/boost-value-depending-on-number-of-common-terms/315267/1 "2022-09-27T14:05:10Z")

</div>

Assuming we have index called `users` and each of them have hobbies stored as array of strings like :`["basketball", "games"]`.  
We want to fetch users with common hobbies, although we want to boost users with more than one mutual hobby. Let's say if it is 1 common hobby, then boost value should be 1, if it is 2 common hobbies then boost should be 3 and if it is 3 common hobbies or more it should be 5.

Is it possible with `terms_set` query? Should it be somehow wrapped with `function_score`?

```auto
      terms_set: {
        hobbies: {
          terms: userDoingQuery.hobbies,
          minimum_should_match_script: {
            source: ???,
          },
          boost: ???,
        },
      }

```

---

<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:** [October 25, 2022, 2:05pm UTC](https://discuss.elastic.co/t/boost-value-depending-on-number-of-common-terms/315267/2 "2022-10-25T14:05:48Z")

</div>

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