elasticsearch - 理解elasticsearch查询分数解释

标签 elasticsearch lucene tf-idf cosine-similarity

我正在尝试破译 elasticsearch 响应中的解释 API。但是有点失落。对我来说有点难理解。任何可以更具体地解释 JSON 的简单指针或链接?我对 VSM 中的 TF、IDF 和余弦相似度有所了解。但更具体地需要一些关于 JSON 的指示。理想情况下,如果我能找到一个简单的数学表达式来解释这个 JSON。

{
  "_explanation": {
    "value": 7.937373,
    "description": "sum of:",
    "details": [
      {
        "value": 2.4789724,
        "description": "weight(FirstName:M80806 in 35) [PerFieldSimilarity], result of:",
        "details": [
          {
            "value": 2.4789724,
            "description": "score(doc=35,freq=1.0), product of:",
            "details": [
              {
                "value": 0.37350902,
                "description": "queryWeight, product of:",
                "details": [
                  {
                    "value": 6.6369815,
                    "description": "idf(docFreq=720, maxDocs=202323)"
                  },
                  {
                    "value": 0.056276944,
                    "description": "queryNorm"
                  }
                ]
              },
              {
                "value": 6.6369815,
                "description": "fieldWeight in 35, product of:",
                "details": [
                  {
                    "value": 1,
                    "description": "tf(freq=1.0), with freq of:",
                    "details": [
                      {
                        "value": 1,
                        "description": "termFreq=1.0"
                      }
                    ]
                  },
                  {
                    "value": 6.6369815,
                    "description": "idf(docFreq=720, maxDocs=202323)"
                  },
                  {
                    "value": 1,
                    "description": "fieldNorm(doc=35)"
                  }
                ]
              }
            ]
          }
        ]
      },
      {
        "value": 2.6825092,
        "description": "weight(FirstName:M8086 in 35) [PerFieldSimilarity], result of:",
        "details": [
          {
            "value": 2.6825092,
            "description": "score(doc=35,freq=1.0), product of:",
            "details": [
              {
                "value": 0.38854012,
                "description": "queryWeight, product of:",
                "details": [
                  {
                    "value": 6.9040728,
                    "description": "idf(docFreq=551, maxDocs=202323)"
                  },
                  {
                    "value": 0.056276944,
                    "description": "queryNorm"
                  }
                ]
              },
              {
                "value": 6.9040728,
                "description": "fieldWeight in 35, product of:",
                "details": [
                  {
                    "value": 1,
                    "description": "tf(freq=1.0), with freq of:",
                    "details": [
                      {
                        "value": 1,
                        "description": "termFreq=1.0"
                      }
                    ]
                  },
                  {
                    "value": 6.9040728,
                    "description": "idf(docFreq=551, maxDocs=202323)"
                  },
                  {
                    "value": 1,
                    "description": "fieldNorm(doc=35)"
                  }
                ]
              }
            ]
          }
        ]
      },
      {
        "value": 2.7758915,
        "description": "weight(FirstName:MHMT in 35) [PerFieldSimilarity], result of:",
        "details": [
          {
            "value": 2.7758915,
            "description": "score(doc=35,freq=1.0), product of:",
            "details": [
              {
                "value": 0.3952451,
                "description": "queryWeight, product of:",
                "details": [
                  {
                    "value": 7.0232153,
                    "description": "idf(docFreq=489, maxDocs=202323)"
                  },
                  {
                    "value": 0.056276944,
                    "description": "queryNorm"
                  }
                ]
              },
              {
                "value": 7.0232153,
                "description": "fieldWeight in 35, product of:",
                "details": [
                  {
                    "value": 1,
                    "description": "tf(freq=1.0), with freq of:",
                    "details": [
                      {
                        "value": 1,
                        "description": "termFreq=1.0"
                      }
                    ]
                  },
                  {
                    "value": 7.0232153,
                    "description": "idf(docFreq=489, maxDocs=202323)"
                  },
                  {
                    "value": 1,
                    "description": "fieldNorm(doc=35)"
                  }
                ]
              }
            ]
          }
        ]
      }
    ]
  }
}

最佳答案

使用 Ruby gem elasticsearch-explain-response ,您将获得更具可读性的“解释”,例如

require 'elasticsearch'
client = Elasticsearch::Client.new
result = client.explain index: "megacorp", type: "employee", id: "1", q: "last_name:Smith"
puts Elasticsearch::API::Response::ExplainResponse.new(result["explanation"]).render
#=>
1.0 = 1.0(fieldWeight)
  1.0 = 1.0(tf(1.0)) x 1.0(idf(2/3)) x 1.0(fieldNorm)
    1.0 = 1.0(termFreq=1.0)

关于elasticsearch - 理解elasticsearch查询分数解释,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/33306058/

相关文章:

lucene - Solr 关联

mysql - 如何在 MySQL 中标记字符串?

python - 文字云 : Bigger font for lower tf-idf values

docker - 使用 .NET 客户端在 ElasticSearch 上定义索引模板

java - NoNodeAvailableException : None of the configured nodes are available

php - 寻找实际有效的数据库抽象/替代

python - 为 TfidfVectorizer scikit-learn 使用自定义词汇表的问题

database - 将数据从 Splunk 移动到 Elastic Search

hadoop - 在hadoop上安装和配置elasticsearch

lucene - 倒排索引 vs 二叉树 vs ...?