lucene-java-user mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From "Eric Isakson" <Eric.Isak...@sas.com>
Subject RE: Sorting by Score
Date Wed, 01 Feb 2006 20:13:05 GMT
Am I understanding your problem correctly?

If you have two hits:

Hit A   score = .7876546   rounded score = .79    date 2006Feb01
Hit B   score = .7907536   rounded score = .79    date 2006Jan01

You would like to have the hits sorted as A, B but you are getting the hits in the order B,
A because they are sorted before you are able to round off the scores.

I've not used the sorting code yet, but it looks like you have to provide some custom ScoreDocComparator
by adding a SortField using the SortField(String field, SortComparatorSource comparator) constructor.
I'm just not certain what you should specify for the field value since you really want to
just round off the score.

Could someone with more experience using the Sort API clarify whether this is possible?
 

-----Original Message-----
From: Daniel.Clark@sybase.com [mailto:Daniel.Clark@sybase.com] 
Sent: Wednesday, February 01, 2006 7:24 AM
To: java-user@lucene.apache.org
Subject: Sorting by Score


My primary sort is by relevance score and my secondary sort is by date.
The Hits.getScore() method returns the score by 7 digits to the right of the decimal point.
 Therefore, If I round to only 2 decimal points in the display, the underlying 7 point score
will be different in the sort.

Example:   score = .7876546   Display score = 79%        The two scores
should be equal in sort.
            score = .7907536  Display score = 79%

How do I convert the score in the Hits.getScore() method to sort to the rounded 2 decimal
point float like the score displayed?  Any help will be appreciated.

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Daniel Clark, Senior Consultant
Sybase Federal Professional Services
6550 Rock Spring Drive, Suite 800
Bethesda, MD  20817
Office - (301) 896-1103
Office Fax - (301) 896-1604
Mobile - (703) 403-0340
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: java-user-unsubscribe@lucene.apache.org
For additional commands, e-mail: java-user-help@lucene.apache.org


Mime
View raw message