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 Toan V Luu <lu...@gmail.com> on 2012/06/01 17:30:06 UTC

Sorting with customized function of score

Hi,
When i use "sort=score asc" then it works, but when I use a customized
function like "sort=sum(score,2) asc" then I got an error "can not sort on
multivalued field: sum(score,2)". Do you know why and how to solve it?
Thanks
Toan.

Re: Sorting with customized function of score

Posted by Chris Hostetter <ho...@fucit.org>.
: I'm using the solr 4.0 nightly build version. In fact I intend to sort with
: a more complicate function including score, geodist() and other factors, so
: this example is to simplify the issue that I cannot sort with a customized
: function of score.
: More concrete, how can i make the sort like:
: sort=product(div(1,geodist()),score) desc ?

in order to include a "score" of a query in a function (any function, 
regardless of where/how you are using that function -- in this case in a 
"sort") you need to be explict about the query whose score you want to use 
via the "query()" function.

So something like this would probably do what you want...

q=whatever_your_query_is&sort=product(div(1,geodist()),query($q))+desc

...but i believe it would be more efficient as ...

qq=whatever_your_query_is&q={!boost+b=div(1,geodist())+v=$qq}&sort=score+desc


-Hoss

Re: Sorting with customized function of score

Posted by Toan V Luu <lu...@gmail.com>.
I'm using the solr 4.0 nightly build version. In fact I intend to sort with
a more complicate function including score, geodist() and other factors, so
this example is to simplify the issue that I cannot sort with a customized
function of score.
More concrete, how can i make the sort like:
sort=product(div(1,geodist()),score) desc ?
Thanks,
Toan.

On Sun, Jun 3, 2012 at 2:56 PM, Erick Erickson <er...@gmail.com>wrote:

> What version of Solr are you using? When I try this with 3.6
> I get an error that "score is not defined".
>
> But what are you trying to accomplish with this particular sort, it
> won't actually do anything at all to your sort order or are you just
> experimenting?
>
> Best
> Erick
>
> On Fri, Jun 1, 2012 at 11:30 AM, Toan V Luu <lu...@gmail.com> wrote:
> > Hi,
> > When i use "sort=score asc" then it works, but when I use a customized
> > function like "sort=sum(score,2) asc" then I got an error "can not sort
> on
> > multivalued field: sum(score,2)". Do you know why and how to solve it?
> > Thanks
> > Toan.
>

Re: Sorting with customized function of score

Posted by Erick Erickson <er...@gmail.com>.
What version of Solr are you using? When I try this with 3.6
I get an error that "score is not defined".

But what are you trying to accomplish with this particular sort, it
won't actually do anything at all to your sort order or are you just
experimenting?

Best
Erick

On Fri, Jun 1, 2012 at 11:30 AM, Toan V Luu <lu...@gmail.com> wrote:
> Hi,
> When i use "sort=score asc" then it works, but when I use a customized
> function like "sort=sum(score,2) asc" then I got an error "can not sort on
> multivalued field: sum(score,2)". Do you know why and how to solve it?
> Thanks
> Toan.