es 精确匹配评分_ElasticSearch相关度评分算法

本文详细介绍了Elasticsearch中精确匹配评分的原理,包括TF-IDF概念、布尔模型、向量空间模型以及Lucene的评分算法。讨论了相关度评分的优化方法,如query time boost、negative boost、constant_score,并讲解了如何自定义function_score函数来调整字段分数。
摘要由CSDN通过智能技术生成

01 TF&IDF概念

TF

Term frequency:搜索文本中的各个词条在field文本中出现了多少次,出现次数越多,就越相关

term在一个doc中出现的次数,出现的次数越多,分数越高

IDF

Inverse document frequencry:搜索文本中的各个词条出现了多少次,出现的次数越多,越不相关

term在所有的doc中出现的次数,出现的次数越多,分数越低

length Norm

term搜索的那个Field的长度,长度越长,相关度越低,分数越低;长度越短,分数越高

最后结合TF,IDF,length Norm综合评分,得到该term对doc的最终分数

如何计算score

GET /website/article/1/_explain{  "query": {    "match": {      "title": "title"    }  }}
{  "_index" : "website",  "_type" : "article",  "_id" : "1",  "matched" : true,  "explanation" : {    "value" : 0.2876821,    "description" : "weight(title:title in 0) [PerFieldSimilarity], result of:",    "details" : [      {        "value" : 0.2876821,        "description" : "score(doc=0,freq=1.0 = termFreq=1.0), product of:",        "details" : [          {            "value" : 0.2876821,            "description" : "idf, computed as log(1 + (docCount - docFreq + 0.5) / (docFreq + 0.5)) from:",            "details" : [              {                "value" : 1.0,                "description" : "docFreq",                "details" : [ ]              },              {                "value" : 1.0,                "description" : "docCount",                "details" : [ ]              }            ]          },          {            "value" : 1.0,            "description" : "tfNorm, computed as (freq * (k1 + 
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值