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 ac <ch...@gmail.com> on 2009/05/19 02:32:58 UTC

CustomScoreQuery numerical precision problem

hello,
I am using CustomScoreQuery for result ranking.
A field of my documents is parsable as an integer value, the magnide
of which exceeds the precision of the float type.
A sample value of this field is 24118569

However, due to the nature of CustomScoreQuery, a cast from int to
float is performed during the scoring( in the class
IntFieldSource), this cause the number from the example to become
24118568 (off by 1) (on a Pentium D 3.2GHz, 32bit OpenSuse 10.3, JDK
1.6.0_13)
This is problematic, because this value is then used as the key to
perform a database query.

I think I can get that cache from IntFieldSource or make my own, then
just lookup that array during customScore().

Any other suggestions ?


thanks!

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


Re: CustomScoreQuery numerical precision problem

Posted by Simon Willnauer <si...@googlemail.com>.
Hi there

On Tue, May 19, 2009 at 8:32 AM, ac <ch...@gmail.com> wrote:
> hello,
> I am using CustomScoreQuery for result ranking.
> A field of my documents is parsable as an integer value, the magnide
> of which exceeds the precision of the float type.
> A sample value of this field is 24118569
>
> However, due to the nature of CustomScoreQuery, a cast from int to
> float is performed during the scoring( in the class
> IntFieldSource), this cause the number from the example to become
> 24118568 (off by 1) (on a Pentium D 3.2GHz, 32bit OpenSuse 10.3, JDK
> 1.6.0_13)
> This is problematic, because this value is then used as the key to
> perform a database query.
>
> I think I can get that cache from IntFieldSource or make my own, then
> just lookup that array during customScore().
That's the way to go! Make sure you override public float
customScore(int doc, float subQueryScore, float valSrcScores[]) if you
have more than one ValueSourceQueries.

simon

>
> Any other suggestions ?
>
>
> thanks!
>
> ---------------------------------------------------------------------
> 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