# Can a Boosting Query be applied to multiple values of a given field?

**URL:** https://discuss.elastic.co/t/can-a-boosting-query-be-applied-to-multiple-values-of-a-given-field/66472
**Category:** Elasticsearch
**Created:** [November 18, 2016, 1:55am UTC](https://discuss.elastic.co/t/can-a-boosting-query-be-applied-to-multiple-values-of-a-given-field/66472 "2016-11-18T01:55:51Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![leporello](https://avatars.discourse-cdn.com/v4/letter/l/d9b06d/32.png) [@leporello](https://discuss.elastic.co/u/leporello)
#### Post date: [November 18, 2016, 1:55am UTC](https://discuss.elastic.co/t/can-a-boosting-query-be-applied-to-multiple-values-of-a-given-field/66472/1 "2016-11-18T01:55:51Z")

</div>

Hi guys,

Re 5.0 Boosting Queries  
[https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-boosting-query.html](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-boosting-query.html)

I'm interested in the best way to boost scores based on the importance of kinds of text (e.g. titles, comments), etc.

I'm experimenting with a mapping that uses a nested object containing 2 fields: text and weight, and I want to boost scores at query time based on the values of the weight field.

Is this possible with the "boosting" query? From results using the query below, I see that the docs that match the "positive" clause are boosted, but scores for other docs are unchanged. Am I doing something wrong?

```auto
{
  "query": {
    "bool": {
      "must": {
        "nested": {
          "path": "content",
          "score_mode": "avg",
          "query": {
            "bool": {
              "must":
                [
                  {"match": {"content.text": "aid"} }
                ],
              "should": 
                 {"boosting": {
                    "positive": {
                      "term" : {"content.weight": 2}
                    },
                    "negative": {
                      "term" : {"content.weight": 0}
                    },                    
                    "negative_boost": 0.5
                  }
                 }
            }
          }
          }
        }                   
      }
  }  
}

```

I have documents with weight values of 0,1,2; the only scores affected based on my tests are those with weight 2.

Thanks!

---

<div class="post-metadata">

### Author: ![jpountz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jpountz/32/45836_2.png) [@jpountz](https://discuss.elastic.co/u/jpountz)
#### Post date: [November 18, 2016, 10:05am UTC](https://discuss.elastic.co/t/can-a-boosting-query-be-applied-to-multiple-values-of-a-given-field/66472/2 "2016-11-18T10:05:13Z")

</div>

Given your use-case, it might be simpler and more flexible to use `script_score`. [https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-function-score-query.html#function-script-score](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-function-score-query.html#function-script-score)

---

<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 16, 2016, 10:05am UTC](https://discuss.elastic.co/t/can-a-boosting-query-be-applied-to-multiple-values-of-a-given-field/66472/3 "2016-12-16T10:05:41Z")

</div>

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