elasticsearch - 在 Elasticsearch 中的 multi_match 查询中获取分数分割

标签 elasticsearch

示例查询:

{
    "from": 0,
    "query": {
        "filtered": {
            "query": {
                "bool": {
                    "should": [{
                        "multi_match": {
                            "fields": ["title", "categories.Name"],
                            "query": "chinese",
                            "tie_breaker": 1,
                            "type": "most_fields"
                        }
                    }]
                }
            }
        }
    },
    "size": 5
}

查询说明:

此查询在字段 title 上执行 multi_match和 categories.Name .
它返回一个分数。

我想要的是:

我想看看分数明细。例如

理想情况下:
{
   "_score": 0.3,
   "_scoreBreakdown": {
     "title": 0.1,
     "categories.Name": 0.2
   }
}

解释设置的问题

将 explain 设置为 true 的问题是,输出不是机器可读的
    "_explanation": {
      "value": 1.5284284,
      "description": "product of:",
      "details": [
        {
          "value": 4.585285,
          "description": "sum of:",
          "details": [
            {
              "value": 4.585285,
              "description": "weight(categories.Name:Pizza in 238) [PerFieldSimilarity], result of:",
              "details": [
                {
                  "value": 4.585285,
                  "description": "score(doc=238,freq=1.0), product of:",
                  "details": [
                    {
                      "value": 0.7233293,
                      "description": "queryWeight, product of:",
                      "details": [
                        {
                          "value": 6.3391395,
                          "description": "idf(docFreq=2, maxDocs=625)"
                        },
                        {
                          "value": 0.114105284,
                          "description": "queryNorm"
                        }
                      ]
                    },
                    {
                      "value": 6.3391395,
                      "description": "fieldWeight in 238, product of:",
                      "details": [
                        {
                          "value": 1,
                          "description": "tf(freq=1.0), with freq of:",
                          "details": [
                            {
                              "value": 1,
                              "description": "termFreq=1.0"
                            }
                          ]
                        },
                        {
                          "value": 6.3391395,
                          "description": "idf(docFreq=2, maxDocs=625)"
                        },
                        {
                          "value": 1,
                          "description": "fieldNorm(doc=238)"
                        }
                      ]
                    }
                  ]
                }
              ]
            }
          ]
        },
        {
          "value": 0.33333334,
          "description": "coord(1/3)"
        }
      ]
    }

所以上面的内容很难分析和分配权重。是否有更机器可读的解释格式?

最佳答案

您可以使用explain API得到这个

关于elasticsearch - 在 Elasticsearch 中的 multi_match 查询中获取分数分割,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38733408/

相关文章:

scala - elastic4s地理距离排序查询语法

elasticsearch - 如何索引html内容,保持位置(如xpath,css选择器等)

elasticsearch - Logstash中的日期过滤器:不良结果(显示一天后)

elasticsearch - Elasticsearch-基于 float 组的余弦相似度排序

elasticsearch - Elasticsearch:常量数据字段类型

Elasticsearch:找到被删除的文档?

docker - 使用 Docker Compose 启动多节点集群 - 在哪里配置主机实际名称?

elasticsearch - 满足数组中所有条件的查询

elasticsearch - 多个单词在搜索中充当单个单词-Elasticsearch

elasticsearch - 重命名和删除 Elasticsearch 索引