How to modify default _score to 0?

I tried function_score query with some filters whose weights are less than 1. However, the max_score of the result is 1 by default (documents matches none of the filters are scored 1 by default).

Here is my simplified query:

{
    "size": 5,
    "explain": true,
    "_source":["sku"],
    "query": {
        "function_score": {
            "query": {
                "bool": {
                    "should": [
                        {
                            "match": {
                                "cid3": "1591"
                            }
                        }
                    ]
                }
            },
            "functions": [
                {
                    "filter": {
                        "match": {
                            "brand_id": "27776"
                        }
                    },
                    "weight": 0.58
                }
            ],
            "score_mode": "sum",
            "boost_mode": "replace"
        }
    }
}

I enabled the explain switch then the result is:

{
  "took" : 1,
  "timed_out" : false,
  "_shards" : {
    "total" : 5,
    "successful" : 5,
    "skipped" : 0,
    "failed" : 0
  },
  "hits" : {
    "total" : 352,
    "max_score" : 1.0,       ## what I want is 0.58
    "hits" : [
      {
        "_shard" : "[flashsale][0]",
        "_node" : "Z0W0-rIfS2qkx3cpsOYhwA",
        "_index" : "flashsale",
        "_type" : "_doc",
        "_id" : "5030920",
        "_score" : 1.0,
        "_source" : {
          "sku" : "5030920"
        },
        "_explanation" : {
          "value" : 1.0,
          "description" : "min of:",
          "details" : [
            {
              "value" : 1.0,   ## And I wonder if this default value could be reset to 0
              "description" : "No function matched",
              "details" : [ ]
            },
            {
              "value" : 3.4028235E38,
              "description" : "maxBoost",
              "details" : [ ]
            }
          ]
        }
      }
    ]
  }
}

Please don't post images of text as they are hardly readable and not searchable.

Instead paste the text and format it with </> icon. Check the preview window.

Could you provide a full recreation script as described in About the Elasticsearch category. It will help to better understand what you are doing. Please, try to keep the example as simple as possible.

A full reproduction script will help readers to understand, reproduce and if needed fix your problem. It will also most likely help to get a faster answer.

Thanks for the suggestion:)

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