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 Yonik Seeley <yo...@lucidimagination.com> on 2009/08/28 23:41:14 UTC

Re: how to selectively sort records keeping some at the bottom always.. ?

On Thu, Aug 27, 2009 at 10:29 AM, Preetam Rao<bl...@gmail.com> wrote:
> Hi,
> If I have documents of type a, b and c but when I sort by some criteria,
> lets say date,
> can I make documents of kind c always appear at the bottom ?

One way is to simply use sorting.
You could have a string field called "type_c" with
sortMissingFirst="true" (see the example schema)
Index "yes" for all documents that are of type_c
Then to sort by date, use sort=type_c desc, date desc

If one needed to put type c docs at the top or bottom, then index "1"
for type c and "2" for other types, and then sort asc or desc as
needed.

-Yonik
http://www.lucidimagination.com


> So effectively I want one kind of records always appear at the bottom since
> they don't have valid data,
> whether sort is ascending or descending;
>
> Would a function query help here ? Or is it even possible ?
>
> Thanks
> Preetam
>

Re: how to selectively sort records keeping some at the bottom always.. ?

Posted by Preetam Rao <bl...@gmail.com>.
Thanks Yonik. It was very useful.

On Sat, Aug 29, 2009 at 3:11 AM, Yonik Seeley <yo...@lucidimagination.com>wrote:

> On Thu, Aug 27, 2009 at 10:29 AM, Preetam Rao<bl...@gmail.com>
> wrote:
> > Hi,
> > If I have documents of type a, b and c but when I sort by some criteria,
> > lets say date,
> > can I make documents of kind c always appear at the bottom ?
>
> One way is to simply use sorting.
> You could have a string field called "type_c" with
> sortMissingFirst="true" (see the example schema)
> Index "yes" for all documents that are of type_c
> Then to sort by date, use sort=type_c desc, date desc
>
> If one needed to put type c docs at the top or bottom, then index "1"
> for type c and "2" for other types, and then sort asc or desc as
> needed.
>
> -Yonik
> http://www.lucidimagination.com
>
>
> > So effectively I want one kind of records always appear at the bottom
> since
> > they don't have valid data,
> > whether sort is ascending or descending;
> >
> > Would a function query help here ? Or is it even possible ?
> >
> > Thanks
> > Preetam
> >
>