Skip to content

Script score doesn't support weight correctly #21483

@sandejain

Description

@sandejain

Elasticsearch version:
"cluster_name": "elasticsearch", "version": { "number": "2.4.0", "build_hash": "ce9f0c7394dee074091dd1bc4e9469251181fc55", "build_timestamp": "2016-08-29T09:14:17Z", "build_snapshot": false, "lucene_version": "5.5.2" }, "tagline": "You Know, for Search"

Plugins installed: []

JVM version:

OS version:

Description of the problem including expected versus actual behavior:
Structure of my query is following:

{
 "query": {
   "function_score": {
     "query": {
       "bool": {
         "disable_coord": "true",
         "should": [
           ... some match_phrase clauses....
         ],
      }
    },
          "functions": [
      {"script_score": {"script": "_score"}, "weight": 0.8},
      {"exp": { "datefield": { "offset": "1d", "scale": "24w", "decay": 0.5 } } , "weight": 0.2}
     ],
    "score_mode": "avg",
    "boost_mode": "replace"
}

Here's what I am trying to do:

Final score needs to be = 0.9 * (_score returned by bool "relevance" query) + 0.1 * (_score returned by exp function)/(0.9 + 0.1)

However, the "replace" boost ends up mucking up with original _score of the query which is clearly not expected.

I tried using "sum" and "multiply" and both of these work in that:

for "sum"
final score = _score + (0.9*_score + 0.1 * score returned by exp)

for "multiply"
final score = _score * (0.9 *_score + 0.1 * score returned by exp)

Any ideas?

Metadata

Metadata

Assignees

No one assigned

    Labels

    :Search/SearchSearch-related issues that do not fall into other categories>buggood first issuelow hanging fruit

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions