You are viewing a plain text version of this content. The canonical link for it is here.
Posted to java-user@lucene.apache.org by Dmitry Serebrennikov <dm...@earthlink.net> on 2002/10/15 19:14:34 UTC

Re: lucene-user Digest 15 Oct 2002 12:32:47 -0000 Issue 170

>
>
>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:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>


Re: lucene-user Digest 15 Oct 2002 12:32:47 -0000 Issue 170

Posted by Peter Carlson <ca...@bookandhammer.com>.
If I understand you correctly, you want to calculate a score which will 
be automatically sorted appropriately.

How are you suggesting sorting by a field value without getting the 
data from the field?

I like the idea.

Also, the SearchBean startup is relatively fast at startup, only about 
3sec for about 100K records. This could also be cached once it's read 
from the index and load time would be much faster.

--Peter


On Tuesday, October 15, 2002, at 10:14 AM, Dmitry Serebrennikov wrote:

>>
>>
>> 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:   
> <ma...@jakarta.apache.org>
> For additional commands, e-mail: 
> <ma...@jakarta.apache.org>
>
>


--
To unsubscribe, e-mail:   <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>