How to use specific filter score in score function script

Hi everyone,

I want to execute the following query in order to get a score that combines many conditions. Each result must respect a precondition (query) and each filter in functions must have a role in calculating output score. I realised that _score in script_score always returns main query score value while I need specific filter condition score (e.g. description match).

{"query":
  {"function_score":
    {
    "query":
      {"match":{"supplierName":{"query":"Company","operator":"OR","prefix_length":0,"max_expansions":50,"fuzzy_transpositions":true,"lenient":false,"zero_terms_query":"NONE","auto_generate_synonyms_phrase_query":true,"boost":1}}},
    "functions":[
          {"filter":{"terms":{"num":["43412453"],"boost":1}},"weight":44.4},
          {"filter":{"match":{"supplierName":{"query":"Company","operator":"OR","prefix_length":0,"max_expansions":50,"fuzzy_transpositions":true,"lenient":false,"zero_terms_query":"NONE","auto_generate_synonyms_phrase_query":true,"boost":1}}},"script_score":{"script":{"source":"Math.min(_score, 1) * 33.333336","lang":"painless"}}},
          {"filter":{"match":{"description":{"query":"Product X","operator":"OR","prefix_length":0,"max_expansions":50,"fuzzy_transpositions":true,"lenient":false,"zero_terms_query":"NONE","auto_generate_synonyms_phrase_query":true,"boost":1}}},"script_score":{"script":{"source":"Math.min(_score / 3.08, 1) * 22.2","lang":"painless"}}}
        ],
        "score_mode":"sum",
        "boost_mode":"replace",
        "min_score":40.0,
        "boost":1
      }
  }      
}

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