您的位置:首页 > 其它

Lucene/solr的评分公式

2012-08-24 11:17 435 查看


1. lucene 评分公式


评分公式中,对大多数因子的控制和实现都是通过Similarity抽象类的子类完成的。lucene默认使用DefaultSimilarity类。如果要详细了解的话可以直接看lucene源代码Similarity和DefaultSimilarity类。



Lucene Scoring 评分机制:

http://blog.chenlb.com/2009/08/lucene-scoring-architecture.html

2.Lucene的评分(score)机制的简单解释

3. dismax/edismax评分公式

3.1 dismax介绍:

What’s a “DisMax” ?:
http://searchhub.org/dev/2010/05/23/whats-a-dismax/

solr dismax/edismax :

http://wiki.apache.org/solr/DisMax

http://wiki.apache.org/solr/ExtendedDisMax

使用solr时可以在solrconfig.xml的<requestHandler name="search">结点中增加defType的设置:

<requestHandler name="search" class="solr.SearchHandler" default="true">
<lst name="defaults">
<str name="defType">edismax</str>	<!--增加这一行-->
</lst>
</requesHandler>


3.2 solr使用edismax时的评分公式

solr管理页面查询时增加参数debugQuery=true即可启用debug信息,可以清楚的看到在查询多个域时评分规则如下:

下面借用用python的对齐方式来展示计算规则:
score = max plus 0.1 times others of:
value1 = field1 weight,product of:
queryWeight, product of:
boost
idf
queryNorm
fieldWeight, product of:
tf(termFreq)
idf
fieldNorm

...
valuen = fieldn weight(计算方法同上)


假设有field1,field2,且field1 weight > field2 weight(即value1 > value2), 那么score = value1 plus 0.1 times value2(即score = value1 + 0.1 * value2)

其中field weight时lucene的评分公式计算出来的,可以看出跟lucene用explain query显示的格式一样。

4.评分相关的Solr FAQ

How can I increase the score for specific
documents
Query Elevation Component
index-time boosts
Field Based Boosting

How
can I change the score of a document based on the *value* of a field (say, "popularity")
How are documents scored
How can I boost the score of newer documents

以上内容是基于当前solr4.4版本的~
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  lucene search solr score