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 user 01 <us...@gmail.com> on 2013/10/04 22:52:08 UTC

Sort by score & an int field value

I need to sort documents returned in order of (descending)score &
(descending)value of an int field within the document. How do I ensure
proper sort order as well as good performance ?

I don't need the sort-order defined by sort=score desc,intField desc. The
sort order needs to be somewhat like what will be delivered using product
function of score*fieldVal as effective score for sort order. But I don't
need exact product for sorting. Approximations are ok, & this is just to
roughly define the sort order I need.

I can see a few possible ways to accomplish this:

*1. Use a customized function of score for sort*

*2. Use query time boost to increase the score using the int field value
for boost*

I'm new to Solr & don't understand the performance implications of each of
above case. Also, don't know if there are other better ways to accomplish
what I am trying to do. So how do I build *performance friendly query to
achieve this sort order* ?

Re: Sort by score & an int field value

Posted by Erick Erickson <er...@gmail.com>.
First, it's rather unlikely that very many docs have the exact same
score, but I have seen it happen.

Second, you can specify sort by function using a bunch of
manipulations available
on the int field.

Best,
Erick

On Fri, Oct 4, 2013 at 4:52 PM, user 01 <us...@gmail.com> wrote:
> I need to sort documents returned in order of (descending)score &
> (descending)value of an int field within the document. How do I ensure
> proper sort order as well as good performance ?
>
> I don't need the sort-order defined by sort=score desc,intField desc. The
> sort order needs to be somewhat like what will be delivered using product
> function of score*fieldVal as effective score for sort order. But I don't
> need exact product for sorting. Approximations are ok, & this is just to
> roughly define the sort order I need.
>
> I can see a few possible ways to accomplish this:
>
> *1. Use a customized function of score for sort*
>
> *2. Use query time boost to increase the score using the int field value
> for boost*
>
> I'm new to Solr & don't understand the performance implications of each of
> above case. Also, don't know if there are other better ways to accomplish
> what I am trying to do. So how do I build *performance friendly query to
> achieve this sort order* ?