lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Dmitry Serebrennikov <dmit...@earthlink.net>
Subject Re: lucene-user Digest 15 Oct 2002 12:32:47 -0000 Issue 170
Date Tue, 15 Oct 2002 17:14:34 GMT
>
>
>As results are sorted by score, you just need to look at the first to
>set the score normalizer. The following code is from Hits.java:
>
>    float scoreNorm = 1.0f;
>    if (length > 0 && scoreDocs[0].score > 1.0f)
>      scoreNorm = 1.0f / scoreDocs[0].score;
>
>    int end = scoreDocs.length < length ? scoreDocs.length : length;
>    for (int i = hitDocs.size(); i < end; i++)
>      hitDocs.addElement(new HitDoc(scoreDocs[i].score*scoreNorm,
>				    scoreDocs[i].doc));
>
>scoreNorm guarantees that all scores will be between 0 and 1.
>
Thanks for the suggestion and a good point. I didn't think of this. 
However, I still don't think I can use this trick because the code I am 
writing will run in a HitCollector that receives hits from multiple 
indexes (such as the one in MultiSearcher). There, hits arrive in order 
in which they are found, which is the insertion order. So I don't know 
when a hit with the highest score will come about.

Dmitry.



--
To unsubscribe, e-mail:   <mailto:lucene-user-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:lucene-user-help@jakarta.apache.org>


Mime
View raw message