# How can I fix a query dsl so that ALL documents are boosted in the function\_score?

**URL:** <https://discuss.elastic.co/t/how-can-i-fix-a-query-dsl-so-that-all-documents-are-boosted-in-the-function-score/346839>\
**Category:** Elasticsearch\
**Created:** [November 10, 2023, 7:05am UTC](https://discuss.elastic.co/t/how-can-i-fix-a-query-dsl-so-that-all-documents-are-boosted-in-the-function-score/346839 "2023-11-10T07:05:45Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kirill\_Cyber](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/kirill_cyber/32/126178_2.png) [@Kirill\_Cyber](https://discuss.elastic.co/u/Kirill_Cyber)\
**Post date:** [November 10, 2023, 7:05am UTC](https://discuss.elastic.co/t/how-can-i-fix-a-query-dsl-so-that-all-documents-are-boosted-in-the-function-score/346839/1 "2023-11-10T07:05:45Z")

</div>

I have dsl query with structure

```auto
{
    "query": {
        "function_score": {
            "query": {
                "bool": {
                    "must": {
                        "multi_match": {
                            "query": "TEST QUERY",
                            "type": "best_fields",
                            "fields": [.......],
                            "operator": "and"
                        }
                    }
                }
            },
            "field_value_factor": {
                "field": "SearchTuning.FIELD_WHICH_INCREASE_SCORE",
                "factor": 100,
                "missing": 0
            },
            "boost_mode": "replace"
        }
    }
}

```

I expect that all documents in the index, not just those that match with "TEST QUERY" and "query" section, will be modified through "field\_value\_factor" and documents with the field "FIELD\_WHICH\_INCREASE\_SCORE" will receive maximum score.

However, in fact, the “hits” array shows that only documents that satisfy the query section are received. All resulting documents in "hits" have score = 0.0 and there is no document in which the field "SearchTuning.FIELD\_WHICH\_INCREASE\_SCORE" exists.

How to correct the query to get the desired result?

---

<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:** [December 8, 2023, 7:05am UTC](https://discuss.elastic.co/t/how-can-i-fix-a-query-dsl-so-that-all-documents-are-boosted-in-the-function-score/346839/2 "2023-12-08T07:05:49Z")

</div>

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