# Adding a negative boost in a multi\_match query

**URL:** <https://discuss.elastic.co/t/adding-a-negative-boost-in-a-multi-match-query/335534>\
**Category:** Elasticsearch\
**Created:** [June 8, 2023, 1:04pm UTC](https://discuss.elastic.co/t/adding-a-negative-boost-in-a-multi-match-query/335534 "2023-06-08T13:04:32Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![daansk44](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/daansk44/32/122015_2.png) [@daansk44](https://discuss.elastic.co/u/daansk44)\
**Post date:** [June 8, 2023, 1:04pm UTC](https://discuss.elastic.co/t/adding-a-negative-boost-in-a-multi-match-query/335534/1 "2023-06-08T13:04:32Z")

</div>

Hi everyone,

I just started with Elastic Search I wanted to make some items in the query less relevant, so I am trying to give them a negative boost (make the two items in the must\_not sub-query less relevant).

And example of my code:

```auto
          query: {
            bool: {
                should: [
                    {
                        multi_match: {
                            query: searchQueryString,
                            fields: ['someType^10', 'someName^4'],
                            type: 'best_fields',
                            operator: 'or',
                            fuzziness: 'AUTO',
                        },
                    },
                    {
                        multi_match: {
                            query: searchQueryString,
                            fields: ['someType^10', 'someName^4'],
                            type: 'phrase',
                            operator: 'or',
                        },
                    },
                ],
              minimum_should_match: '2',
              must_not: [
                  {
                      terms: {
                          type: ['xxxx', 'xxxy'],
                      },
                  },
              ],
              negative_boost: 0.5,
            },
                must: searchCriteria,
            },

```

I've added the type terms `xxxx` and `xxxy` a negative boost, but the response from Elasticsearch is:

```auto
message
: 
"x_content_parse_exception" 

```

When the must\_not statement is remove, the code can query Elasticsearch, but when I add this the error above is returned.

```auto
              must_not: [
                  {
                      terms: {
                          type: ['xxxx', 'xxxy'],
                      },
                  },
              ],
              negative_boost: 0.5,
            },
                must: searchCriteria,
            },

```

Did I make a typo of some kind, of is there another way to do this?

---

<div class="post-metadata">

**Author:** ![Hemanth\_Gowda](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hemanth_gowda/32/23886_2.png) [@Hemanth\_Gowda](https://discuss.elastic.co/u/Hemanth_Gowda)\
**Post date:** [June 10, 2023, 2:32am UTC](https://discuss.elastic.co/t/adding-a-negative-boost-in-a-multi-match-query/335534/2 "2023-06-10T02:32:15Z")

</div>

```auto
{
"query": {
  "bool": {
    "should": [
      {
        "multi_match": {
          "query": "",
          "fields": []
        }
      },
      {
        "multi_match": {
          "query": "",
          "fields": []
        }
      }
    ],
    "minimum_should_match": 1,
    "must_not": [
      {
        "terms": {
          "FIELD": [
            "VALUE1",
            "VALUE2"
          ],
          "boost": 0.5
        }
      }
    ]
  }
}
}

```

Please try using boost instead if negative\_boost. Defaul boost is 1. So if you configure 0.5 it will reduce the boost for specified terms. If it still doesn't solve your problem, you should consider using [Boosting query | Elasticsearch Guide [8.8] | Elastic](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-boosting-query.html)

---

<div class="post-metadata">

**Author:** ![daansk44](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/daansk44/32/122015_2.png) [@daansk44](https://discuss.elastic.co/u/daansk44)\
**Post date:** [June 13, 2023, 11:58am UTC](https://discuss.elastic.co/t/adding-a-negative-boost-in-a-multi-match-query/335534/3 "2023-06-13T11:58:13Z")

</div>

Yes, this was where I was searching for. Thank you 🙂

---

<div class="post-metadata">

**Author:** ![daansk44](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/daansk44/32/122015_2.png) [@daansk44](https://discuss.elastic.co/u/daansk44)\
**Post date:** [June 13, 2023, 2:52pm UTC](https://discuss.elastic.co/t/adding-a-negative-boost-in-a-multi-match-query/335534/4 "2023-06-13T14:52:49Z")

</div>

To fast 🦖 🦖 It seems that it will just remote the item from the result, no matter the score

```js
should: [
    {
        multi_match: {
            query: searchQueryString,
            fields: ['xxx^10', 'xxxx^4', 'xxx^4'],
            type: 'best_fields',
            operator: 'or',
            fuzziness: 'AUTO',
        },
    },
    {
        multi_match: {
            query: searchQueryString,
            fields: ['xxx^10', 'xxxx^4', 'xxx^4'],
            type: 'phrase',
            operator: 'or',
        },
    },
],
    minimum_should_match: '1',
    must_not: [
    {
        terms: {
            type: ['item1', 'item2'],
            boost: 0.5,
        },
    },
],

```

---

<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 11, 2023, 2:53pm UTC](https://discuss.elastic.co/t/adding-a-negative-boost-in-a-multi-match-query/335534/5 "2023-07-11T14:53:46Z")

</div>

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