You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@lucene.apache.org by Nick Smith <ni...@techop.ch> on 2003/09/01 16:32:37 UTC

Issue with Similarity and negative numbers

Hi Luceners!

I am misusing the document score for date sorting (I display news
headlines in a chronological list).

As the document score is ultimately encoded as a byte the maximum
possible number of values is 256 minus the special value of 0
(document not found).

In the current implementation; all negative float values get
rounded up to zero by Similarity.floatToByte() and the method
Similarity.byteToFloat() returns only values in the range of
1 to 127 values that are greater than the decode for the
next lower byte value.

i.e. 
Similarity.byteToFloat(byteVal+1) > Similarity.byteToFloat(byteVal)

For my application having 255 possible scores from searches was better
than 127 so....

I have patched the Similarity class to encode negative floats into
the negative byte values and to decode the negative byte values back
into negative floats.

The encoding of the positive values are unchanged by this patch.

Could this version please be checked into CVS by someone with commit
rights?  Or is there are a more formal procedure to submitting patches,
say via the Bugzilla?

Many Thanks,

Nick Smith