Elasticsearch:结合功能分数

时间:2018-03-05 12:22:42

标签: elasticsearch search

我用三个{ "query": { "function_score": { "query": { "bool": { ... } } } }, "score_mode": "multiply", "boost_mode": "replace", "functions": [ { f1 }, { f2 }, { f3 } ] } 评分es查询:

f1(doc) * f2(doc) * f3(doc)

所以分数为:f1(doc) * f2(doc) + f3(doc)

但我想要的是{{1}},任何解决方案?

2 个答案:

答案 0 :(得分:0)

这可能有效,即我们将函数f1和f2的得分相乘,然后我们将该得分添加到查询得分,这是另一个function_score查询仅适用于f3。

{
  "query": {
    "function_score": {
      "query": {
        "function_score": {
          "query": { "match_all": {}},
          "functions": [
            {
              "f3": {...}
            }
          ]
        }
      },
      "functions": [
        {
          "f1": {...}
        },
        {
          "f2": {...}
        }
      ],
      "score_mode": "multiply",
      "boost_mode": "sum"
    }
  }
}

答案 1 :(得分:-1)

分数模式

总和选项

"score_mode": "sum",

这应该可以让你得分。

见f.e. https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-function-score-query.html