lucene 评分机制研究(debug信息)
lucene评分公式

文档结果:
{ "id": 4111005, "bookType": 2, "title": "故宫", "userId": "xxx", "userName": "xxx", "routeDays": 1, "startTime": 1310313600000, "cTime": 1407243889812, "uTime": 1407244293220, "avgPrice": 0, "actorType": 0, "tripType": 0, "platform": 0, "quality": 5365590, "travelMonths": 64, "sourceId": -1, "labelName": "", "imageUrl": "xxx", "travelRouteTabbed": "故宫", "travelRoute": "故宫", "destCitiesTabbed": "北京", "destCitiesGrouped": "北京", "destCities": "北京", "destProvinces": "", "destNations": "中国", "destNationsText": "中国", "destContinents": "亚洲", "destContinentsText": "亚洲", "poiIdTabbed": "710603", "distIds": "299914\t300667", "provinceName": "", "nationName": "", "continentName": "", "disallowed": "", "viewCount": 36, "quoteCount": 0, "downloadCount": 0, "ugcType": 2, "ugcTime": 1407244293220, "destWeights": "{\"中国\":1.0,\"北京\":1.0,\"china\":1.0}", "fingerPrint": "153a926f3b27c63889b5dc3e9b69f9ba", "_version_": 1497957597913809000, "score": 145735744, "payload": "score:145735744,matchscore:14.573575,destscore:0.0" }
得分debug信息,DefaultSimilarity
1 '4111005'=>'//ID号 2 14.557129 = (MATCH) sum of://最后得分 = 11.167477(相似性评分) + 3.3896518(boost query打分) 3 11.167477 = (MATCH) max of://相似性评分(max of :11.167477(命中标题得分),0.40179574(命中途径得分)取其中最大的?)
// DisjunctionMaxScore源码中对于score的计算为 scoreMax + (scoreSum - scoreMin) * tieBreakerMultipliter
// tieBreadkerMultipiler传值为0,所以最后就只取最大的匹配值
###################################### 命中标题部分 ##################################### 4 11.167477 = (MATCH) weight(title:故宫^3.0 in 212390) [DefaultSimilarity], result of://命中标题得分明细 5 11.167477 = score(doc=212390,freq=1.0 = termFreq=1.0)// queryWeight * fieldWeight 6 , product of: //score = queryWeight * fieldWeight = boost * idf * queryNorm * tf * idf * fieldNorm // = tf * idf^2 * boost * fieldNorm * queryNorm //score + score = (tf * idf^2 * boost * fieldNorm + tf * idf^2 *boost *fieldNorm) * queryNorm 与评分公式一致 7 0.99955523 = queryWeight, product of://queryWeight 为什么不等于boost * idf ?压缩误差? 8 3.0 = boost //qf=title^3 相当于termQuery.setBoost(3.0) 公式:boost(t.field in d) 9 11.172446 = idf(docFreq=44, maxDocs=1177741)//逆向文本频率idf(docFreq:该term出现的doc数量44,maxDocs:所有doc数量1177741) 10 0.029822035 = queryNorm //查询权重,不影响排序,多个查询比较使用 公式queryNorm(q)部分 11 11.172446 = fieldWeight in 212390, product of://fieldWeight 12 1.0 = tf(freq=1.0), with freq of: //该term的词频,对应公式tf(t in d)部分 13 1.0 = termFreq=1.0 //该term在本doc中出现的次数 14 11.172446 = idf(docFreq=44, maxDocs=1177741) //逆向文本频率idf(t)部分 15 1.0 = fieldNorm(doc=212390)//公式中lengthNorm部分=state.getboost()*(1/maths.sqrt(numTerms)) numTerms为对应field的term数量 state.getboost()创建索引指定field权重,例中title就是故宫,分词切成一个term,故numTerms=1 #################################### 命中途径部分 ####################################### 16 0.40179574 = (MATCH) weight(travelRouteTabbed:故宫^0.5 in 212390) [DefaultSimilarity], result of://命中途径得分 17 0.40179574 = score(doc=212390,freq=1.0 = termFreq=1.0) 18 , product of: 19 0.07740273 = queryWeight, product of: 20 0.5 = boost //qf=travelRouteTabbed:故宫^0.5 21 5.190976 = idf(docFreq=17820, maxDocs=1177741) //逆向文本频率idf(docFreq:该term出现的doc数量17820,maxDocs:所有doc数量1177741) 22 0.029822035 = queryNorm //查询权重,不影响排序,多个查询比较使用 公式queryNorm(q)部分 23 5.190976 = fieldWeight in 212390, product of: 24 1.0 = tf(freq=1.0), with freq of: 25 1.0 = termFreq=1.0 26 5.190976 = idf(docFreq=17820, maxDocs=1177741) 27 1.0 = fieldNorm(doc=212390) ##################################### boost funtion部分 ################################# // 就debug信息来看 没有打印出公式中的coord部分,而是使用lucene原有的公式加上了bf的分数,bf最后的得分依照product of来看应该是 // sum * boost * queryNorm来得出,那么bf所需要定制的分值就需要考虑乘以queryNorm之后的分数再去影响lucene自身的score,是不是把queryNorm设置为1比较好 // 因为queryNorm对排序的结果没有影响,最终的结果只会被所有命中term的累加和分数再加上bf分数影响,那么coord去哪里呢? 28 3.3896518 = (MATCH) FunctionQuery(sum(rord(routeDays),2000000.0/(1.0*float(rord(quality))+20000.0))), product of://boost query打分) 29 113.66266 = sum(rord(routeDays)=76,2000000.0/(1.0*float(rord(quality)=33103)+20000.0))//bf值的设定 30 1.0 = boost//默认权重是1 31 0.029822035 = queryNorm'

浙公网安备 33010602011771号