# Function\_score boost\_mode broken in version 5

**URL:** https://discuss.elastic.co/t/function-score-boost-mode-broken-in-version-5/64674
**Category:** Elasticsearch
**Created:** [November 2, 2016, 6:44am UTC](https://discuss.elastic.co/t/function-score-boost-mode-broken-in-version-5/64674 "2016-11-02T06:44:10Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![davidbkemp](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/davidbkemp/32/594_2.png) [@davidbkemp](https://discuss.elastic.co/u/davidbkemp)
#### Post date: [November 2, 2016, 6:44am UTC](https://discuss.elastic.co/t/function-score-boost-mode-broken-in-version-5/64674/1 "2016-11-02T06:44:10Z")

</div>

I am having problems with "function\_score" queries involving the combination of a query with a list of functions.

I get the impression that the "boost\_mode" is being ignored. This used to work in version 2.4.0

Here is an example.

Start with these four documents:

```auto
POST /test/test/1
{
  "description": "banana",
  "date": "2016-01-01"
}

POST /test/test/2
{
  "description": "orange",
  "date": "2016-02-01"
}

POST /test/test/3
{
  "description": "banana",
  "date": "2016-03-01"
}

POST /test/test/4
{
  "description": "orange",
  "date": "2016-04-01"
}

```

The following query returns the three desired documents, but they all get scores of zero.

If I replace the bool/filter with bool/must, I get scores of 6 and 4 even though the "replace" directive should have resulted in scores of 3 and 2.  
If I use "explain=true" it looks like it is still multiplying the query score by the weights.  
If I go back to my original bool/filter but remove the second ("gte") range filter, then one of the documents gets a score of 2, but the others get scores of zero.

Note: the query seems to work in version 2.4.0, but not in 5.0.0

```auto
GET /test/test/_search
{
  "query": {
    "function_score": {
      "boost_mode": "replace",
      "score_mode": "max",
      "query": {
        "bool": {
          "filter": [
            {
              "range": {
                "date": {
                  "lte": "2016-03-01"
                }
              }
            },
            {
              "range": {
                "date": {
                  "gte": "2015-01-01"
                }
              }
            }
          ]
        }
      },
      "functions": [
        {
          "weight": 3,
          "filter": {
            "match": {
              "description": "banana"
            }
          }
        },
        {
          "weight": 2,
          "filter": {
            "match": {
              "description": "orange"
            }
          }
        }
      ]
    }
  }
}

```

---

<div class="post-metadata">

### Author: ![davidbkemp](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/davidbkemp/32/594_2.png) [@davidbkemp](https://discuss.elastic.co/u/davidbkemp)
#### Post date: [February 11, 2017, 2:56am UTC](https://discuss.elastic.co/t/function-score-boost-mode-broken-in-version-5/64674/2 "2017-02-11T02:56:09Z")

</div>

This has now been fixed in version 5.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: [July 5, 2017, 10:03pm UTC](https://discuss.elastic.co/t/function-score-boost-mode-broken-in-version-5/64674/3 "2017-07-05T22:03:22Z")

</div>


