Explain

调试是掌握任何框架的第一步,在Elastic中通过Explain调试为什么某个字段的分数那么高

测试数据,我们采用Demo数据中的SKU作为参数,它是keyword类型

GET kibana_sample_data_ecommerce/_search?explain=true
{
  "_source": ["sku"], 
  "query": {
    "term": {
      "sku": "ZO0450004500"
    }
  }
}

返回的Explain

-- -- 7.5339074
weight(sku:ZO0450004500 in 55) [PerFieldSimilarity], result of:
	-- -- 7.5339074
	score(doc=55,freq=1.0 = termFreq=1.0\n), product of:
		-- 7.5339074
		idf, computed as log(1 + (docCount - docFreq + 0.5) / (docFreq + 0.5)) from:
			-- 2.0(kibana_sample_data_ecommerce中符合条件的个数)
			docFreq
			-- 4675.0(kibana_sample_data_ecommerce的总个数)
			docCount
		-- 1.0
      	tfNorm, computed as (freq * (k1 + 1)) / (freq + k1) from:
      		-- 1.0
      		termFreq=1.0
      		-- 1.2
      		parameter k1(1.2)
      		-- 0
			parameter b (norms omitted for field)(0)