Function_score with several functions

Could somebody point me to the right direction? :nerd_face:

I'm trying to search items and categorize / score them based on several criteria.
function_score seems to do all the right things except I it just returns total sum of scores instead of scores for each functions.

{
  "query": {
    "function_score": {
      "query": {
        "match_all": {}
      },
      "functions": [
        {
          "filter": {
            "match": {
              "industry.group.code": "A"
            }
          },
          "weight": 70
        },
        {
          "filter": {
            "match": {
              "name": "Apple"
            }
          },
          "weight": 30
        }
      ],
      "score_mode": "sum",
      "boost_mode": "sum",
      "min_score": 42
    }
  }
}

I've been trying to add missing scores fields by using script_score but failed so far.

{
  "filter": {
    "match": {
      "industry.group.code": "A"
    }
  },
  "script_score": {
    "script": {
      "lang": "painless",
      "source": "ctx._source.score_industry == _score // <-- THIS DOESNT WORK; return _score;"
    }
  },
  "weight": 70
}

I found this topic but it seemed to be quite old

So I'm wondering if it's possible to add new fields under script_score or are there any alternative way to do this?

I would appreciate your comments about this :stuck_out_tongue_winking_eye:

Can anyone push me to the right direction? :grimacing:

Anyone?

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