# Scoring script not applied with bool query

**URL:** <https://discuss.elastic.co/t/scoring-script-not-applied-with-bool-query/60504>\
**Category:** Elasticsearch\
**Created:** [September 14, 2016, 12:27pm UTC](https://discuss.elastic.co/t/scoring-script-not-applied-with-bool-query/60504 "2016-09-14T12:27:54Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![ndtreviv](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ndtreviv/32/22494_2.png) [@ndtreviv](https://discuss.elastic.co/u/ndtreviv)\
**Post date:** [September 14, 2016, 12:27pm UTC](https://discuss.elastic.co/t/scoring-script-not-applied-with-bool-query/60504/1 "2016-09-14T12:27:54Z")

</div>

I have a custom native scoring script (hamming distance), installed on an elasticsearch v2.3.1, and I'm applying it in my query like so:

```
curl -XPOST 'http://localhost:9200/myindex/_search?pretty' -d '{
      "query": {
        "function_score": {     
          "min_score": 14,
          "query":{
           "bool": {
                     "minimum_should_match": 6,
                     "should": [
                        {
                           "fuzzy": {
                              "myField0": {
                                 "value": "10110110",
                                 "fuzziness": 2
                              }
                           }
                        },
                        ...
                        {
                           "fuzzy": {
                              "myField7": {
                                 "value": "10010100",
                                 "fuzziness": 2
                              }
                           }
                        }
                     ]
                  }
          },
          "functions": [
            {
              "script_score": {
                "script": "hamming_distance",
                "lang" : "native",
                "params": {
                  "param_hash": "myhash",
                  "param_field":"myField"
                }
              }
            }
          ]
        }
      }
    }'

```

The problem is that the scoring script is not being applied. If I change the query type to a filtered query, then it works - the scoring script is applied, but then I can't generate this query using the Java API because `filteredQuery` is deprecated in favour of using `boolQuery`s.

Can anyone advise what I should be doing? Should I be doing bools with filters nested or something? Thanks for any help!

---

<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:20pm UTC](https://discuss.elastic.co/t/scoring-script-not-applied-with-bool-query/60504/2 "2017-07-05T22:20:17Z")

</div>


