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/01/24 14:50:26 UTC

Similarity.encodeNorm() / decodeNorm() funny.

Hi Luceners,
   I'm (mis)using the field normalisation factor for my own
sorting purposes.  I create a sorting indicator as a byte
value and use Similarity.decodeNorm() to create the float
value suitable and have encounter the following :

I made the assumption that

  encodeNorm(decodeNorm(abyte)) == abyte

i.e. it is reflexive function.

However the assumption is value for values 1-7 (values
-128 to 0 and 1 to 127 are as expected) - see below...

in = 0 float = 0.0 out = 0
in = 1 float = 5.820766E-10 out = 8
in = 2 float = 6.9849193E-10 out = 8
in = 3 float = 8.1490725E-10 out = 8
in = 4 float = 9.313226E-10 out = 8
in = 5 float = 1.1641532E-9 out = 8
in = 6 float = 1.3969839E-9 out = 8
in = 7 float = 1.6298145E-9 out = 8
in = 8 float = 1.8626451E-9 out = 8
in = 9 float = 2.3283064E-9 out = 9

Now that I know of this "feature" I can workaround it
but using only the range 9-127 (which is enough in my
case).

I've posted this because it has caused a mistifying
problem in our product and others _might_ be encountering
the same "feature".

Many Thanks for the work people do on Lucene!!!

Cheers,

Nick


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


Re: Similarity.encodeNorm() / decodeNorm() funny.

Posted by Doug Cutting <cu...@lucene.com>.
Looks like a bug.  I just patched Similarity.java to fix this.

Doug


Nick Smith wrote:
> Hi Luceners,
>    I'm (mis)using the field normalisation factor for my own
> sorting purposes.  I create a sorting indicator as a byte
> value and use Similarity.decodeNorm() to create the float
> value suitable and have encounter the following :
> 
> I made the assumption that
> 
>   encodeNorm(decodeNorm(abyte)) == abyte
> 
> i.e. it is reflexive function.
> 
> However the assumption is value for values 1-7 (values
> -128 to 0 and 1 to 127 are as expected) - see below...
> 
> in = 0 float = 0.0 out = 0
> in = 1 float = 5.820766E-10 out = 8
> in = 2 float = 6.9849193E-10 out = 8
> in = 3 float = 8.1490725E-10 out = 8
> in = 4 float = 9.313226E-10 out = 8
> in = 5 float = 1.1641532E-9 out = 8
> in = 6 float = 1.3969839E-9 out = 8
> in = 7 float = 1.6298145E-9 out = 8
> in = 8 float = 1.8626451E-9 out = 8
> in = 9 float = 2.3283064E-9 out = 9
> 
> Now that I know of this "feature" I can workaround it
> but using only the range 9-127 (which is enough in my
> case).
> 
> I've posted this because it has caused a mistifying
> problem in our product and others _might_ be encountering
> the same "feature".
> 
> Many Thanks for the work people do on Lucene!!!
> 
> Cheers,
> 
> Nick
> 
> 
> --
> 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>