# Bool query with boost for should clause

**URL:** <https://discuss.elastic.co/t/bool-query-with-boost-for-should-clause/323555>\
**Category:** Elasticsearch\
**Created:** [January 20, 2023, 12:39am UTC](https://discuss.elastic.co/t/bool-query-with-boost-for-should-clause/323555 "2023-01-20T00:39:48Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![seeminglee](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/seeminglee/32/109766_2.png) [@seeminglee](https://discuss.elastic.co/u/seeminglee)\
**Post date:** [January 20, 2023, 12:39am UTC](https://discuss.elastic.co/t/bool-query-with-boost-for-should-clause/323555/1 "2023-01-20T00:39:48Z")

</div>

How can you add boost to specific part of a should query. For example:

```auto
{
  "query": {
    "bool": {
      "should": [
        {"term":{"fruit.keyword":"apple"}},
        {"term":{"fruit.keyword":"banana"}},
        {"term":{"fruit.keyword":"orange"}},
      ],
      "minimum_should_match": 2
    }
  }
}

```

If say I want to boost `apple` by a factor of 2 — meaning apple is twice as important as banana or orange. Is there a way to do it? I tried to use compound bool with boost but it didn’t work (i.e. nesting a bool inside each should).

The docs suggest that I should be able to do it with query string:

```auto
{
  "query": {
    "query_string": {
      "query": "fruit.keyword:apple^2 OR fruit.keyword:banana OR fruit.keyword:orange",
      "minimum_should_match": 2
    }
  }
}

```

But I would ideally like to do it with `bool` since it makes code more manageable. If it’s possible, how?

I’m using ES 6.8

---

<div class="post-metadata">

**Author:** ![RabBit\_BR](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/rabbit_br/32/82261_2.png) [@RabBit\_BR](https://discuss.elastic.co/u/RabBit_BR)\
**Post date:** [January 20, 2023, 1:33am UTC](https://discuss.elastic.co/t/bool-query-with-boost-for-should-clause/323555/2 "2023-01-20T01:33:55Z")

</div>

Hi @seeminglee

You tried using boost like this:

```auto
{
          "term": {
            "fruit.keyword": {
              "value": "apple",
              "boost": 2
            }
          }
        }

```

---

<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:** [February 17, 2023, 1:34am UTC](https://discuss.elastic.co/t/bool-query-with-boost-for-should-clause/323555/3 "2023-02-17T01:34:37Z")

</div>

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