开发者

understanding the relationship between boosting a document in lucene at index time and its corresponding score at search time

开发者 https://www.devze.com 2023-04-13 07:05 出处:网络
When indexing, I boost certain documents, but they do not appear on the top of the list of retrieved documents. I looked at the score of those documents, and somehow, the score of the documents retrie

When indexing, I boost certain documents, but they do not appear on the top of the list of retrieved documents. I looked at the score of those documents, and somehow, the score of the documents retrieved is always NaN.

What is the relationship between a boost of a document at index time and its score at retrieve time? I thought these would be correlated, and further, I thought I would get a wide range of scores in my scoredocs, not just NaN. If you can shed some light on this I would be grateful.

I have read http://lucene.apache.org/java/2_3_2/api/org/apache/lucene/search/Similarity.html

and cant figure out what 开发者_开发知识库is missing.

Here is the simple boosting code:

if (myCondition)  
{
   myDocument.SetBoost(1.1f);
}
myIndexWriter.AddDocument(document);


I'm gonna go on a wild guess here since you havent provide a sample of you search code, but a common reason why the score of retreived docs is NaN is because you use a Sort. When sorting, most of the time the score of the documents is not used, and therefore disabled by default.

If you use a Sort for your search, and want the score, check the method setDefaultFieldSortScoring of the IndexSearcher class. This method allows you to enable scoring the documents in a search that uses a Sort.

http://lucene.apache.org/java/2_9_4/api/all/org/apache/lucene/search/IndexSearcher.html#setDefaultFieldSortScoring(boolean, boolean)

0

精彩评论

暂无评论...
验证码 换一张
取 消