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 Jörg Kiegeland <ki...@ikv.de> on 2008/01/11 19:04:23 UTC

Sorting within groups of equal-scored result documents

Hello,

I have a query of the form (a or b).

Documents matching this query are returned in the order how many 
conditions are actually fullfilled.
E.g.

1. doc matching a and b
2. doc matching a and b
3. doc matching a
4. doc matching a
5. doc matching a
6. doc matching b

Now I want, that within groups (1.+2.)  and  (3.+4.+5+6..), items shall 
be ordered by a field. However defining a sorting field (via 
addSortField()) performs a global sort, not considering my primary sort 
criteria (namely how many conditions match).
Can one do a sort within these groups?

Re: Sorting within groups of equal-scored result documents

Posted by Yonik Seeley <yo...@apache.org>.
If you already have a sort that works for you, you could do a
secondary sort by your field via
sort=score desc,myfield asc

The sort would need to score all the docs in each group equally for
this secondary sort to work (you didn't say if you've achieved that
yet).

-Yonik

On Jan 11, 2008 1:04 PM, Jörg Kiegeland <ki...@ikv.de> wrote:
> Hello,
>
> I have a query of the form (a or b).
>
> Documents matching this query are returned in the order how many
> conditions are actually fullfilled.
> E.g.
>
> 1. doc matching a and b
> 2. doc matching a and b
> 3. doc matching a
> 4. doc matching a
> 5. doc matching a
> 6. doc matching b
>
> Now I want, that within groups (1.+2.)  and  (3.+4.+5+6..), items shall
> be ordered by a field. However defining a sorting field (via
> addSortField()) performs a global sort, not considering my primary sort
> criteria (namely how many conditions match).
> Can one do a sort within these groups?
>

Re: Sorting within groups of equal-scored result documents

Posted by Erick Erickson <er...@gmail.com>.
I did something like this in low-level Lucene using
FieldSortedHitQueue. The searchable lucene users
list should have more details.

Don't know how to do it in SOLR though...

Erick

On Jan 11, 2008 1:04 PM, Jörg Kiegeland <ki...@ikv.de> wrote:

> Hello,
>
> I have a query of the form (a or b).
>
> Documents matching this query are returned in the order how many
> conditions are actually fullfilled.
> E.g.
>
> 1. doc matching a and b
> 2. doc matching a and b
> 3. doc matching a
> 4. doc matching a
> 5. doc matching a
> 6. doc matching b
>
> Now I want, that within groups (1.+2.)  and  (3.+4.+5+6..), items shall
> be ordered by a field. However defining a sorting field (via
> addSortField()) performs a global sort, not considering my primary sort
> criteria (namely how many conditions match).
> Can one do a sort within these groups?
>