在Elasticsearch中的multi_match查询中获得分数细分

时间:2016-08-03 02:29:14

标签: elasticsearch

示例查询:

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

查询说明:

此查询对字段titlecategories.Name执行multi_match。 它会返回一个分数。

我想要的是什么:

我希望看到得分细分。 e.g。

理想地:

{
   "_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)"
        }
      ]
    }

所以上面的内容很难分析并用来分配权重。是否有更便于阅读的机器可读格式?

1 个答案:

答案 0 :(得分:0)

您可以使用explain API来获取此