Chinaunix首页 | 论坛 | 博客
  • 博客访问: 2422448
  • 博文数量: 392
  • 博客积分: 7040
  • 博客等级: 少将
  • 技术积分: 4138
  • 用 户 组: 普通用户
  • 注册时间: 2009-06-17 13:03
个人简介

范德萨发而为

文章分类

全部博文(392)

文章存档

2017年(5)

2016年(19)

2015年(34)

2014年(14)

2013年(47)

2012年(40)

2011年(51)

2010年(137)

2009年(45)

分类: Java

2013-06-18 12:44:16

Lucene's default similarity function


Lucene's is defined by the function 


where 
  1. tf(t in d) denotes the term's frequency, defined as the number of times the term t appears in the currently scored document d. Documents that have more occurrences of a given term receive a higher score.The default computation for tf(t in d) in is: 

  2. idf(t) stands for Inverse Document Frequency. This value correlates to the inverse of docFreq (the number of documents in which the term t appears). This means rarer terms give higher contribution to the total score. idf(t) appears for t in both the query and the document, hence it is squared in the equation. The default computation for idf(t) in is: 

  3. coord(q,d) is a score factor based on how many of the query terms are found in the specified document. Typically, a document that contains more of the query's terms will receive a higher score than another document with fewer query terms. This is a search time factor computed in coord(q,d) function by the in effect at search time. 

    where, overlap is the number of query terms matched in the document and maxOverlap the total number of terms in the query.

  4. queryNorm(q) is a normalizing factor used to make scores between queries comparable. This factor does not affect document ranking (since all ranked documents are multiplied by the same factor), but rather just attempts to make scores from different queries (or even different indexes) comparable. This is a search time factor computed by the Similarity in effect at search time. The default computation in produces a : 

    where, the sum of squared weights (of the query terms) is computed by the query  object as: 
    sumOfSquaredWeights = q.getBoost()^ 2 * Sum t in q ( idf(t) * t.getBoost() ) ^2 
    Lucene uses by default the value 1.0 for the factors q.getBoost() and t.getBoost().

  5. t.getBoost() is a search time boost of term t in the query q. Notice that there is really no direct API for accessing a boost of one term in a multi term query, but rather multi terms are represented in a query as multi  objects, and so the boost of a term in the query is accessible by calling the sub-query . 
    The boost is 1.0 by default !

  6. norm(t,d) encapsulates a few (indexing time) boost and length factors: 
    • Document boost - set by calling doc.setBoost() before adding the document to the index. This value is 1.0 by default!
    • Field boost - set by calling field.setBoost() before adding the field to a document. This value is 1.0 by default!
    •  - computed when the document is added to the index in accordance with the number of tokens of this field in the document, so that shorter fields contribute more to the score. LengthNorm is computed by the Similarity class in effect at indexing. This function is defined as lengthNorm(String fieldName,int numTokens) , where fieldName is the name of the field and numTokens is the total number of tokens contained in fields named fieldName of doc. The returning value is a normalization factor for hits on this field of this document.
阅读(1447) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~