【问题标题】:Why does idf value vary for the same term in multiple queried documents in Elasticsearch?为什么 Elasticsearch 中多个查询文档中同一个词的 idf 值不同?
【发布时间】:2016-05-24 21:54:17
【问题描述】:

我正在对我创建的 ES 索引执行查询。该查询由两个词组成,在返回的文档列表中,我看到一个文档的排名高于另一个文档。尽管第一个文档只包含两个术语中的一个,而后者包含两个术语。

我使用 Explain API 查看分数是如何生成的,我发现对于同一个术语“温度”,idf 的计算方式不同。这不是预期的,因为 idf 仅取决于索引中包含术语的文档数和总文档数。此外,我的索引不会随时更改。

这些是从两个 Explain 调用的输出中摘录的。这些包含 idf:

文档1:

"description": 
 "weight(description:temperatur in 0) [PerFieldSimilarity], result of:",
                            "details": [
                              {
                                "value": 0.7007727,
                                "description": "score(doc=0,freq=1.0), product of:",
                                "details": [
                                  {
                                    "value": 0.44917533,
                                    "description": "queryWeight, product of:",
                                    "details": [
                                      {
                                        "value": 3.1202636,
                                        "description": "idf(docFreq=5, maxDocs=50)",
                                        "details": []
                                      },
                                      {
                                        "value": 0.14395429,
                                        "description": "queryNorm",
                                        "details": []
                                      }
                                    ]

文档2:

 "description": "weight(description:temperatur in 21) [PerFieldSimilarity], result of:",
                        "details": [
                          {
                            "value": 1.6804222,
                            "description": "score(doc=21,freq=1.0), product of:",
                            "details": [
                              {
                                "value": 0.61089635,
                                "description": "queryWeight, product of:",
                                "details": [
                                  {
                                    "value": 4.4011974,
                                    "description": "idf(docFreq=1, maxDocs=60)",
                                    "details": []
                                  },
                                  {
                                    "value": 0.1388023,
                                    "description": "queryNorm",
                                    "details": []
                                  }
                                ]

为什么 idf 不同?

【问题讨论】:

    标签: elasticsearch lucene


    【解决方案1】:

    我猜你有不止一个分片,对吧?

    idf 将在该文档的分片内计算,而不是在整个索引上计算。您可以通过添加?search_type=dfs_query_then_fetch 来强制它计算全局 idf。出于性能考虑,建议您不要在生产中使用它。

    更详尽的解释见:Relevance is Broken!

    【讨论】:

    • 是的,5 个分片。感谢您的回答。
    猜你喜欢
    • 2011-06-16
    • 2023-03-23
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2020-09-21
    • 1970-01-01
    • 1970-01-01
    • 2021-04-17
    相关资源
    最近更新 更多