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 okayndc <bo...@gmail.com> on 2011/07/12 21:00:11 UTC

solr/velocity: funtion for sorting asc/desc

hello,

was wondering if there is a solr/velocity function out there that can sort
say, a title name, by clicking on a link named "sort title" that can sort
ascending or descending by alpha?  or is this a frontend/jquery type of
thing?

thanks

--
View this message in context: http://lucene.472066.n3.nabble.com/solr-velocity-funtion-for-sorting-asc-desc-tp3163549p3163549.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: solr/velocity: funtion for sorting asc/desc

Posted by okayndc <bo...@gmail.com>.
Awesome, thanks Erik!

--
View this message in context: http://lucene.472066.n3.nabble.com/solr-velocity-funtion-for-sorting-asc-desc-tp3163549p3167662.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: solr/velocity: funtion for sorting asc/desc

Posted by Erik Hatcher <er...@gmail.com>.
You'll have to add some logic in your Velocity templates string process the sort parameter and determine whether to set the link to be "asc"ending or "desc"ending.  It'll require learning some Velocity techniques to do this with #if and how to navigate the objects Solr puts into the Velocity context.  You'll find pointers to more information here: http://wiki.apache.org/solr/VelocityResponseWriter

I know this doesn't quite get you there without you doing the homework, but maybe there'll be enough pointers in that wiki page to get you there.

I've done this in various one-off cases, but nothing handy to share at the moment (I'm traveling), but maybe in a week or so I'll be able to dig something out or re-craft the voodoo.

	Erik


On Jul 13, 2011, at 14:23 , okayndc wrote:

> Thanks Eric.
> 
> So if I had a link "Sort Title" and the default is &sort=title desc how can
> i switch that to &sort=title asc?
> 
> example:  http://# Sort Tile  (default &sort=title desc)  user clicks on
> link and sort should toggle(or switch) to &sort=title asc
> 
> how can this be achieved?
> 
> 
> --
> View this message in context: http://lucene.472066.n3.nabble.com/solr-velocity-funtion-for-sorting-asc-desc-tp3163549p3167267.html
> Sent from the Solr - User mailing list archive at Nabble.com.


Re: solr/velocity: funtion for sorting asc/desc

Posted by okayndc <bo...@gmail.com>.
Thanks Eric.

So if I had a link "Sort Title" and the default is &sort=title desc how can
i switch that to &sort=title asc?

example:  http://# Sort Tile  (default &sort=title desc)  user clicks on
link and sort should toggle(or switch) to &sort=title asc

how can this be achieved?


--
View this message in context: http://lucene.472066.n3.nabble.com/solr-velocity-funtion-for-sorting-asc-desc-tp3163549p3167267.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: solr/velocity: funtion for sorting asc/desc

Posted by Erick Erickson <er...@gmail.com>.
Velocity should have nothing to do with it, you specify on the query
something like &sort=title asc or &sort=title desc. But do note that
sorting only really makes sense when the field is NOT tokenized. Often
using a combination of a Keyword tokenizer and LowerCaseFilter gives
the results you're looking for...

Best
Erick

On Tue, Jul 12, 2011 at 3:00 PM, okayndc <bo...@gmail.com> wrote:
> hello,
>
> was wondering if there is a solr/velocity function out there that can sort
> say, a title name, by clicking on a link named "sort title" that can sort
> ascending or descending by alpha?  or is this a frontend/jquery type of
> thing?
>
> thanks
>
> --
> View this message in context: http://lucene.472066.n3.nabble.com/solr-velocity-funtion-for-sorting-asc-desc-tp3163549p3163549.html
> Sent from the Solr - User mailing list archive at Nabble.com.
>