lucene内置的评分函数

简介:

For multiterm queries, Lucene takes the Boolean modelTF/IDF, and the vector space model and combines them in a single efficient package that collects matching documents and scores them as it goes.

A multiterm query like

GET /my_index/doc/_search { "query": { "match": { "text": "quick fox" } } }

As soon as a document matches a query, Lucene calculates its score for that query, combining the scores of each matching term. The formula used for scoring is called the practical scoring function. 

score(q,d)  =  

            queryNorm(q)  

          · coord(q,d)    

          · ∑ (           

                tf(t in d)   

              · idf(t)²      

              · t.getBoost() 

              · norm(t,d)    

            ) (t in q)    

score(q,d) is the relevance score of document d for query q.

queryNorm(q) is the query normalization factor (new).

coord(q,d) is the coordination factor (new).

 

The sum of the weights for each term t in the query q for document d.

tf(t in d) is the term frequency for term t in document d.

idf(t) is the inverse document frequency for term t.

t.getBoost() is the boost that has been applied to the query (new).

norm(t,d) is the field-length norm, combined with the index-time field-level boost, if any. (new). 官方不推荐用index-time find level

You should recognize scoretf, and idf. The queryNormcoordt.getBoost, and norm are new.

We will talk more about query-time boosting later in this chapter, but first let’s get query normalization, coordination, and index-time field-level boosting out of the way.

Query Normalization Factor

queryNorm = 1 / √sumOfSquaredWeights 

The sumOfSquaredWeights is calculated by adding together the IDF of each term in the query, squared.

The same query normalization factor is applied to every document, and you have no way of changing it. For all intents and purposes, it can be ignored. (每个文档都有这个因子,说明它没有什么卵用!)

Query Coordination

The coordination factor (coord) is used to reward documents that contain a higher percentage of the query terms. The more query terms that appear in the document, the greater the chances that the document is a good match for the query.

The coordination factor results in the document that contains all three terms being much more relevant than the document that contains just two of them.














本文转自张昺华-sky博客园博客,原文链接:http://www.cnblogs.com/bonelee/p/6475880.html,如需转载请自行联系原作者

相关文章
|
5月前
|
搜索推荐 开发者
如何在 Elasticsearch 中选择精确 kNN 搜索和近似 kNN 搜索
【6月更文挑战第8天】Elasticsearch 是一款强大的搜索引擎,支持精确和近似 kNN 搜索。精确 kNN 搜索保证高准确性但计算成本高,适用于对精度要求极高的场景。近似 kNN 搜索则通过牺牲部分精度来提升搜索效率,适合大数据量和实时性要求高的情况。开发者应根据业务需求和数据特性权衡选择。随着技术发展,kNN 搜索将在更多领域发挥关键作用。
175 4
|
存储 算法 API
Elasticsearch评分相关度算法解析
Elasticsearch评分相关度算法解析
146 0
|
自然语言处理 算法 Java
11Lucene相关度排序
11Lucene相关度排序
57 0
|
Java API Apache
lucene 相关性参考
假期梳理了之前在新浪博客的文档,将一些有用的内容搬到这里。本文是lucene序列原理分享之一:相关性原理。
73 0
|
索引
Elasticsearch 评分排序
背景 通过脚本改变评分 背景 近期有一个需求,需要对优惠券可用商品列表加个排序,只针对面值类的券不包括折扣券。 需求是这样的,假设有一张面值券 50 块钱,可用商品列表 A 100、B 40、C 10,当用户查询当前券可用商品列表的时候优先将卡券可以直接抵扣且不需要用户在额外支付的商品排在前面。
1569 0
|
自然语言处理 算法 索引
下一篇
无影云桌面