1
votes

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);
1
Show some real code. What do you expect?, what is the actual result? etc. Maybe something's wrong with your codeL.B

1 Answers

5
votes

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)