17.explain_api

文章目录

explain api非常有用,一般情况下业务人员如果反馈排序为什么不是预期的样子,如果你使用了es来做排序的话,那么就需要使用它的explain功能来做深度问题排查了
这个explain会给出打分的具体原因,当然,你要稍微熟悉一下es的默认的打分算法BM25

使用

GET /twitter/_explain/0
{
      "query" : {
        "match" : { "message" : "elasticsearch" }
      }
}

返回样例

{
   "_index":"twitter",
   "_type":"_doc",
   "_id":"0",
   "matched":true,
   "explanation":{
      "value":1.6943597,
      "description":"weight(message:elasticsearch in 0) [PerFieldSimilarity], result of:",
      "details":[
         {
            "value":1.6943597,
            "description":"score(freq=1.0), product of:",
            "details":[
               {
                  "value":2.2,
                  "description":"boost",
                  "details":[]
               },
               {
                  "value":1.3862944,
                  "description":"idf, computed as log(1 + (N - n + 0.5) / (n + 0.5)) from:",
                  "details":[
                     {
                        "value":1,
                        "description":"n, number of documents containing term",
                        "details":[]
                     },
                     {
                        "value":5,
                        "description":"N, total number of documents with field",
                        "details":[]
                     }
                  ]
               },
               {
                  "value":0.5555555,
                  "description":"tf, computed as freq / (freq + k1 * (1 - b + b * dl / avgdl)) from:",
                  "details":[
                     {
                        "value":1.0,
                        "description":"freq, occurrences of term within document",
                        "details":[]
                     },
                     {
                        "value":1.2,
                        "description":"k1, term saturation parameter",
                        "details":[]
                     },
                     {
                        "value":0.75,
                        "description":"b, length normalization parameter",
                        "details":[]
                     },
                     {
                        "value":3.0,
                        "description":"dl, length of field",
                        "details":[]
                     },
                     {
                        "value":5.4,
                        "description":"avgdl, average length of field",
                        "details":[]
                     }
                  ]
               }
            ]
         }
      ]
   }
}

可以带的参数

_source

设置为true以返回文档的_source。您还可以使用_source_includes和_source_excludes来检索文档的一部分(有关更多详细信息,请参见获取API)

stored_fields

返回哪些stored_fields

routing
如果在索引编制过程中使用了路由,则控制路由。

parent
与设置路由参数相同。

preference
控制对解释执行的分片。

source
允许将请求的数据放入url的查询字符串中。

q
查询字符串(映射到query_string查询)。

df
在查询中未定义任何字段前缀时使用的默认字段。

analyzer
分析查询字符串时要使用的分析器名称。默认为默认搜索分析器。

analytics_wildcard
是否应分析通配符和前缀查询。默认为false。

lenient
如果设置为true,将导致忽略基于格式的错误(例如,向数字字段提供文本)。默认为false。

default_operator
要使用的默认运算符可以是AND或OR。默认为OR。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值