# Terms query - different boost values depending on matching term

**URL:** <https://discuss.elastic.co/t/terms-query-different-boost-values-depending-on-matching-term/48490>\
**Category:** Elasticsearch\
**Created:** [April 27, 2016, 12:27am UTC](https://discuss.elastic.co/t/terms-query-different-boost-values-depending-on-matching-term/48490 "2016-04-27T00:27:00Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![logless](https://avatars.discourse-cdn.com/v4/letter/l/c0e974/32.png) [@logless](https://discuss.elastic.co/u/logless)\
**Post date:** [April 27, 2016, 12:27am UTC](https://discuss.elastic.co/t/terms-query-different-boost-values-depending-on-matching-term/48490/1 "2016-04-27T00:27:00Z")

</div>

Is it possible to have different boosts for different terms in a terms query (similar to the multimatch query)?

[pseudocode]  
"terms" : {  
"some\_field" : ["value^2", "second\_value^5","third\_value^10"]  
}  
[/pseudocode]

---

<div class="post-metadata">

**Author:** ![softwaredoug](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/softwaredoug/32/22681_2.png) [@softwaredoug](https://discuss.elastic.co/u/softwaredoug)\
**Post date:** [April 27, 2016, 12:51am UTC](https://discuss.elastic.co/t/terms-query-different-boost-values-depending-on-matching-term/48490/2 "2016-04-27T00:51:46Z")

</div>

I'm pretty sure terms query is not scored. I've only ever used for  
filtering, and only for things like ids that aren't analyzed (or that I can  
reason about the analysis pretty easily)

Are you sure you don't just want a series of match queries surrounded by  
bool

For example something like...

```auto
"bool": {
"must": [
{"match": {
"some_field" {
"query": "value"
"boost": 2
}
},
{"match": {
"some_field" {
"query": "second_value"
"boost": 5
}
},
...etc...
]
}

```

This basically sums the result of each match clause's score, biasing  
heavily towards items that have multiple matches.

---

<div class="post-metadata">

**Author:** ![logless](https://avatars.discourse-cdn.com/v4/letter/l/c0e974/32.png) [@logless](https://discuss.elastic.co/u/logless)\
**Post date:** [April 29, 2016, 2:14pm UTC](https://discuss.elastic.co/t/terms-query-different-boost-values-depending-on-matching-term/48490/3 "2016-04-29T14:14:28Z")

</div>

I am trying to implement personalized autocomplete where output would be biased towards user search history. Let's say the user has made 100 searches for 12 items, and each item has been searched for N number of times.

I would need 12 MATCH queries, each with a different boost value, which sounds like an overkill that would degrade performance.

Is there another approach I could implement?

---

<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:** [July 5, 2017, 10:55pm UTC](https://discuss.elastic.co/t/terms-query-different-boost-values-depending-on-matching-term/48490/4 "2017-07-05T22:55:12Z")

</div>


