# Setting score\_mode for queries; like in query\_string-query

**URL:** <https://discuss.elastic.co/t/setting-score-mode-for-queries-like-in-query-string-query/168602>\
**Category:** Elasticsearch\
**Created:** [February 15, 2019, 2:09pm UTC](https://discuss.elastic.co/t/setting-score-mode-for-queries-like-in-query-string-query/168602 "2019-02-15T14:09:49Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![mos](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mos/32/4898_2.png) [@mos](https://discuss.elastic.co/u/mos)\
**Post date:** [February 15, 2019, 2:09pm UTC](https://discuss.elastic.co/t/setting-score-mode-for-queries-like-in-query-string-query/168602/1 "2019-02-15T14:09:49Z")

</div>

In function\_score queries it is possible to adjust the behavior via the score\_mode (max, sum, multiply etc.) Is a similiar configuration possible for other queries?

**Example:**

We have a index definition with default-fields like this:

```
{
  "test_boosting_in_default_field" : {
    "aliases" : { },
    "mappings" : { ..},
     "settings" : {
      "index" : {
        "query" : {
          "default_field" : [
            "ABSTRACT",
            "AUTOR^20",
            "BRANCHE",
            .....

```

Doing a simple query\_string-query we got results, where the \_score is calculated from the "max score of" all fields that matches (--\> max\_score of (ABSTRACT, AUTOR and BRANCHE)..). We don't need the max-score of all searched field; instead we want to multiply scores of all machted fields?

Can this be specified at query-time? Didn't found a configuration for this?

Thanks

---

<div class="post-metadata">

**Author:** ![mos](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mos/32/4898_2.png) [@mos](https://discuss.elastic.co/u/mos)\
**Post date:** [February 19, 2019, 11:16am UTC](https://discuss.elastic.co/t/setting-score-mode-for-queries-like-in-query-string-query/168602/2 "2019-02-19T11:16:40Z")

</div>

anyone?

---

<div class="post-metadata">

**Author:** ![xeraa](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/xeraa/32/48181_2.png) [@xeraa](https://discuss.elastic.co/u/xeraa)\
**Post date:** [February 27, 2019, 6:54pm UTC](https://discuss.elastic.co/t/setting-score-mode-for-queries-like-in-query-string-query/168602/3 "2019-02-27T18:54:11Z")

</div>

I might be totally misreading this, but aren't the [types of a multi match](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-multi-match-query.html#multi-match-types) what you are looking for? Specifically `most_fields` (which is only adding and not multiplying, but it's at least the right direction) instead of `best_fields`?

---

<div class="post-metadata">

**Author:** ![mos](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mos/32/4898_2.png) [@mos](https://discuss.elastic.co/u/mos)\
**Post date:** [February 28, 2019, 8:27am UTC](https://discuss.elastic.co/t/setting-score-mode-for-queries-like-in-query-string-query/168602/4 "2019-02-28T08:27:42Z")

</div>

Kind of. I'm searching such types for the [Query String Query](https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-query-string-query.html) (not a multi match query).  
The String-Query searches per default in the "default\_field"s from the index definition (see above). The score of matches in those fields should be calculated as "most\_fields".  
Is there any configuration option which I missed?

---

<div class="post-metadata">

**Author:** ![xeraa](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/xeraa/32/48181_2.png) [@xeraa](https://discuss.elastic.co/u/xeraa)\
**Post date:** [February 28, 2019, 12:08pm UTC](https://discuss.elastic.co/t/setting-score-mode-for-queries-like-in-query-string-query/168602/5 "2019-02-28T12:08:07Z")

</div>

From what I know this isn't possible with the `query_string` and that's why I used `multi_match`. Generally `query_string` offers a lot of options and is a good starting point, but for finer control it might IMO not be the right choice.

---

<div class="post-metadata">

**Author:** ![mos](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mos/32/4898_2.png) [@mos](https://discuss.elastic.co/u/mos)\
**Post date:** [February 28, 2019, 12:27pm UTC](https://discuss.elastic.co/t/setting-score-mode-for-queries-like-in-query-string-query/168602/6 "2019-02-28T12:27:29Z")

</div>

Thanks @xeraa for helping out. In our use-case we need the full featured query-syntax from the Query String Query. It's a user specific search that uses those operations. Sure, we can rebuild our own String-Query and map it into a very complex Json structure using mulit\_match, bool queries and so on. But that seems to make no sense if we just want to change the behavior of scoring over the different fields....  
Is there any plan (ticket) to config scoring-behavior for a string-query?

---

<div class="post-metadata">

**Author:** ![xeraa](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/xeraa/32/48181_2.png) [@xeraa](https://discuss.elastic.co/u/xeraa)\
**Post date:** [February 28, 2019, 12:46pm UTC](https://discuss.elastic.co/t/setting-score-mode-for-queries-like-in-query-string-query/168602/7 "2019-02-28T12:46:24Z")

</div>

Wait, actually this should be possible: [https://www.elastic.co/guide/en/elasticsearch/reference/6.6/query-dsl-query-string-query.html#\_cross\_field](https://www.elastic.co/guide/en/elasticsearch/reference/6.6/query-dsl-query-string-query.html#_cross_field)

I took a look at the relevant changes and it was added in 6.0: [https://github.com/elastic/elasticsearch/pull/25646](https://github.com/elastic/elasticsearch/pull/25646)

---

<div class="post-metadata">

**Author:** ![mos](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/mos/32/4898_2.png) [@mos](https://discuss.elastic.co/u/mos)\
**Post date:** [February 28, 2019, 12:53pm UTC](https://discuss.elastic.co/t/setting-score-mode-for-queries-like-in-query-string-query/168602/8 "2019-02-28T12:53:32Z")

</div>

Great. I missed that it was integrated in 6.0. Thanks a lot!

---

<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:** [March 28, 2019, 12:53pm UTC](https://discuss.elastic.co/t/setting-score-mode-for-queries-like-in-query-string-query/168602/9 "2019-03-28T12:53:34Z")

</div>

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