【问题标题】:elasticsearch function score, boost weight of "number of matched terms in query" (coordination)elasticsearch函数得分,提升“查询中匹配词数”的权重(协调)
【发布时间】:2018-07-17 00:58:18
【问题描述】:

我想使用 elasticsearch 函数 score 进行自定义评分,这些是我的排名优先事项:

  1. 查询的常用词的数量(例如,在查询中包含 4 个词中的 3 个的文档的排名应该高于在查询中包含 4 个词中的 2 个的文档,无论 tf/idf 分数是多少每个术语)。在弹性文档中它被称为coordination factor

  2. 术语相关性的总和。 (tf/idf)

  3. 文档流行度(boosting by popularity 中描述的每个文档的投票数)

这是当前使用的 elasticsearch 请求正文:

body = {
        "query": {
            "function_score": {
                "query": {
                    {'match': {'text': query}}
                },
                "functions": [
                    {
                        "field_value_factor": {
                            "field": "ducoumnet_popularity",
                        }
                    }
                ],
            }
        }
    }

问题是此请求不满足第一优先级。例如,可能有文档 A 的查询常用词少于文档 B,但由于其常用词的 tf/idf 分数更高,因此文档 A 的排名高于文档 B。

为了防止这种情况,我认为最好的方法是通过协调因素来提高文档的分数。有什么办法吗?类似于此请求的内容:

body = {
        "query": {
            "function_score": {
                "query": {
                    {'match': {'text': query}}
                },
                "functions": [
                    {
                        "field_value_factor": {
                            "field": "ducoumnet_popularity",
                        },
                        "field_value_factor": {
                            "field": "_coordination"
                            "weight": 10
                        }
                    }
                ],
            }
        }
    }

【问题讨论】:

  • 你得到这个答案了吗?
  • @ayushsinghal 没有 :(
  • 它是重复的,但即使其他问题已被 OP 标记为已回答,我也认为它不是一个令人满意的答案。他们没有提供重新加权分数的不同元素的解决方案。

标签: elasticsearch


【解决方案1】:

我没有找到这个问题的确切答案,但它可以帮助某人知道您可以使用 minimum_should_match 限制结果中文档的最低精度。

{
    "query": {
        "match": {
            "content": {
                "query": "quick brown dog",
                "minimum_should_match": 75%
            }
        }
    }
}

它接受许多不同的配置。更多解释: https://www.elastic.co/guide/en/elasticsearch/reference/current/query-dsl-minimum-should-match.html

【讨论】:

    猜你喜欢
    • 2016-05-15
    • 1970-01-01
    • 1970-01-01
    • 2017-02-11
    • 2018-11-01
    • 2015-04-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多