You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by Derek Springer <de...@mahalo.com> on 2008/11/18 02:17:56 UTC

Query Response Doc Score -> Int Value

Hello,
I am currently performing a query to a Solr index I've set up and I'm trying
to 1) sort on the score and 2) sort on the date_created (a custom field I've
added). The sort command looks like: sort=score+desc,created_date+desc.

The gist of it is that I will 1) first return the most relevant results then
2) within those results, return the most recent results. However, the issue
I have is that the score is a decimal value that is far to precise (e.g.
2.3518934 vs 2.2173865) and will therefore never "collide" and trigger the
secondary sort on the date.

The question I am asking is if anyone knows a way to produce a score that is
more coarse, or if it is possible to force the score to return as an
integer. That way I could have the results collide on the score more often
and therefore sort on the date as well.

Thanks!
-Derek

RE: Query Response Doc Score -> Int Value

Posted by "Nguyen, Joe" <jn...@automotive.com>.
You don't need to hack the code since you can virtually treated these
scores 2.3518934 and 2.2173865 as if they were both equal (ignoring
digits after the decimal point).

Score = original score(2.3518934) + function(date_created)

You can scale the value of function(date_created) so that digits after
the decimal point in the original score are not significantly influent
the final score.

E.g.  
To treat digits after decimal point *insignificant*
     Score  = 2.3518934 + 10.00 = 12.3518934
          
To make those significant, make function(date_created) results in small
number
     Score = 2.3518934 + 0.2   = 2.5518934

You can specify the function in the request URL
(http://wiki.apache.org/solr/FunctionQuery)



  

-----Original Message-----
From: Derek Springer [mailto:derek@mahalo.com] 
Sent: Tuesday, November 18, 2008 8:39 Joe
To: solr-user@lucene.apache.org
Subject: Re: Query Response Doc Score -> Int Value

Better yet, does anyone know where the method that writes the score
lives?
For instance, a getScore() method that writes the score out that I could
override and truncate? Thanks!

-Derek

On Mon, Nov 17, 2008 at 9:59 PM, Derek Springer <de...@mahalo.com>
wrote:

> Thanks for the heads up. Can anyone point me to (or provide me with) 
> an example of writing a function query?
>
> -Derek
>
>
> On Mon, Nov 17, 2008 at 8:17 PM, Yonik Seeley <yo...@apache.org>
wrote:
>
>> A function query is the likely candidate - no such quantization 
>> function exists, but it would be relatively easy to write one.
>>
>> -Yonik
>>
>> On Mon, Nov 17, 2008 at 8:17 PM, Derek Springer <de...@mahalo.com>
wrote:
>> > Hello,
>> > I am currently performing a query to a Solr index I've set up and 
>> > I'm
>> trying
>> > to 1) sort on the score and 2) sort on the date_created (a custom 
>> > field
>> I've
>> > added). The sort command looks like:
sort=score+desc,created_date+desc.
>> >
>> > The gist of it is that I will 1) first return the most relevant 
>> > results
>> then
>> > 2) within those results, return the most recent results. However, 
>> > the
>> issue
>> > I have is that the score is a decimal value that is far to precise
(e.g.
>> > 2.3518934 vs 2.2173865) and will therefore never "collide" and 
>> > trigger
>> the
>> > secondary sort on the date.
>> >
>> > The question I am asking is if anyone knows a way to produce a 
>> > score
>> that is
>> > more coarse, or if it is possible to force the score to return as 
>> > an integer. That way I could have the results collide on the score 
>> > more
>> often
>> > and therefore sort on the date as well.
>> >
>> > Thanks!
>> > -Derek
>> >
>>
>
>
>
> --
> Derek B. Springer
> Software Developer
> Mahalo.com, Inc.
> 902 Colorado Ave.,
> Santa Monica, CA 90401
> derek@mahalo.com
>



--
Derek B. Springer
Software Developer
Mahalo.com, Inc.
902 Colorado Ave.,
Santa Monica, CA 90401
derek@mahalo.com

Re: Query Response Doc Score -> Int Value

Posted by Derek Springer <de...@mahalo.com>.
Better yet, does anyone know where the method that writes the score lives?
For instance, a getScore() method that writes the score out that I could
override and truncate? Thanks!

-Derek

On Mon, Nov 17, 2008 at 9:59 PM, Derek Springer <de...@mahalo.com> wrote:

> Thanks for the heads up. Can anyone point me to (or provide me with) an
> example of writing a function query?
>
> -Derek
>
>
> On Mon, Nov 17, 2008 at 8:17 PM, Yonik Seeley <yo...@apache.org> wrote:
>
>> A function query is the likely candidate - no such quantization
>> function exists, but it would be relatively easy to write one.
>>
>> -Yonik
>>
>> On Mon, Nov 17, 2008 at 8:17 PM, Derek Springer <de...@mahalo.com> wrote:
>> > Hello,
>> > I am currently performing a query to a Solr index I've set up and I'm
>> trying
>> > to 1) sort on the score and 2) sort on the date_created (a custom field
>> I've
>> > added). The sort command looks like: sort=score+desc,created_date+desc.
>> >
>> > The gist of it is that I will 1) first return the most relevant results
>> then
>> > 2) within those results, return the most recent results. However, the
>> issue
>> > I have is that the score is a decimal value that is far to precise (e.g.
>> > 2.3518934 vs 2.2173865) and will therefore never "collide" and trigger
>> the
>> > secondary sort on the date.
>> >
>> > The question I am asking is if anyone knows a way to produce a score
>> that is
>> > more coarse, or if it is possible to force the score to return as an
>> > integer. That way I could have the results collide on the score more
>> often
>> > and therefore sort on the date as well.
>> >
>> > Thanks!
>> > -Derek
>> >
>>
>
>
>
> --
> Derek B. Springer
> Software Developer
> Mahalo.com, Inc.
> 902 Colorado Ave.,
> Santa Monica, CA 90401
> derek@mahalo.com
>



-- 
Derek B. Springer
Software Developer
Mahalo.com, Inc.
902 Colorado Ave.,
Santa Monica, CA 90401
derek@mahalo.com

Re: Query Response Doc Score -> Int Value

Posted by Derek Springer <de...@mahalo.com>.
Thanks for the heads up. Can anyone point me to (or provide me with) an
example of writing a function query?

-Derek

On Mon, Nov 17, 2008 at 8:17 PM, Yonik Seeley <yo...@apache.org> wrote:

> A function query is the likely candidate - no such quantization
> function exists, but it would be relatively easy to write one.
>
> -Yonik
>
> On Mon, Nov 17, 2008 at 8:17 PM, Derek Springer <de...@mahalo.com> wrote:
> > Hello,
> > I am currently performing a query to a Solr index I've set up and I'm
> trying
> > to 1) sort on the score and 2) sort on the date_created (a custom field
> I've
> > added). The sort command looks like: sort=score+desc,created_date+desc.
> >
> > The gist of it is that I will 1) first return the most relevant results
> then
> > 2) within those results, return the most recent results. However, the
> issue
> > I have is that the score is a decimal value that is far to precise (e.g.
> > 2.3518934 vs 2.2173865) and will therefore never "collide" and trigger
> the
> > secondary sort on the date.
> >
> > The question I am asking is if anyone knows a way to produce a score that
> is
> > more coarse, or if it is possible to force the score to return as an
> > integer. That way I could have the results collide on the score more
> often
> > and therefore sort on the date as well.
> >
> > Thanks!
> > -Derek
> >
>



-- 
Derek B. Springer
Software Developer
Mahalo.com, Inc.
902 Colorado Ave.,
Santa Monica, CA 90401
derek@mahalo.com

Re: Query Response Doc Score -> Int Value

Posted by Yonik Seeley <yo...@apache.org>.
A function query is the likely candidate - no such quantization
function exists, but it would be relatively easy to write one.

-Yonik

On Mon, Nov 17, 2008 at 8:17 PM, Derek Springer <de...@mahalo.com> wrote:
> Hello,
> I am currently performing a query to a Solr index I've set up and I'm trying
> to 1) sort on the score and 2) sort on the date_created (a custom field I've
> added). The sort command looks like: sort=score+desc,created_date+desc.
>
> The gist of it is that I will 1) first return the most relevant results then
> 2) within those results, return the most recent results. However, the issue
> I have is that the score is a decimal value that is far to precise (e.g.
> 2.3518934 vs 2.2173865) and will therefore never "collide" and trigger the
> secondary sort on the date.
>
> The question I am asking is if anyone knows a way to produce a score that is
> more coarse, or if it is possible to force the score to return as an
> integer. That way I could have the results collide on the score more often
> and therefore sort on the date as well.
>
> Thanks!
> -Derek
>