# Boost score if field exists with function score

**URL:** <https://discuss.elastic.co/t/boost-score-if-field-exists-with-function-score/191136>\
**Category:** Elasticsearch\
**Created:** [July 18, 2019, 7:34am UTC](https://discuss.elastic.co/t/boost-score-if-field-exists-with-function-score/191136 "2019-07-18T07:34:03Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![hangu\_choi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/hangu_choi/32/49745_2.png) [@hangu\_choi](https://discuss.elastic.co/u/hangu_choi)\
**Post date:** [July 18, 2019, 7:34am UTC](https://discuss.elastic.co/t/boost-score-if-field-exists-with-function-score/191136/1 "2019-07-18T07:34:03Z")

</div>

I want to boost score **if `some_field_4` is exists**

but it return error.  
How can I do this in elasticsearch 7 ?

```auto
reason":"no [query] registered for [function_score]"

```

```auto
{
  "query": {
    "function_score": {
      "query": {
        "bool": {
          "filter": [
            { "terms":{ "some_field_1": ["y"] } },
            { "terms":{ "some_field_2": ["y"] } }
          ]
        }
      },
      "functions": [
        {
          "filter": { "range": { "some_field_3": { "gte": 5 }}},
          "weight": 23
        },
        {
          "query": { "exists": { "field": "some_field_4" } },
          "weight": 50
        }
      ]
    }
  },
  "from": 0,
  "size": 10
  
}

```

---

<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:** [August 15, 2019, 7:42am UTC](https://discuss.elastic.co/t/boost-score-if-field-exists-with-function-score/191136/2 "2019-08-15T07:42:44Z")

</div>

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