cancel
Showing results for 
Search instead for 
Did you mean: 

Searching with multiple sort keys in FreeMarker / Lucene

rivarola
Champ on-the-rise
Champ on-the-rise
Hello,

When running a Lucene query from a template one can specify a "sort_by" clause to sort the results. Is it possible to specify several sort keys instead of onen (for instance lastname and then firstname) ?
5 REPLIES 5

kevinr
Star Contributor
Star Contributor
I'm not sure you can do that in a single op - you may have to call ?sort_by twice.

It might be worth requesting this feature on the FreeMarker dev list.

Thanks,

Kevin

tsgpartner_mui
Champ in-the-making
Champ in-the-making
Kevin,

So is there a way to sort by more than one field?  Because I was unable to do figure out a way.   I want to be able to sort by multiple properties of an object.  Could you provide a simple example of how a person would call sort_by twice in a list for freemarker??  Would that be the way to go, or you don't know for sure


Thanks

kevinr
Star Contributor
Star Contributor
I've not tried to do it myself.

Kevin

savic_prvoslav
Champ on-the-rise
Champ on-the-rise
hell yea, this works.

current.children?sort_by('type')?sort_by(['properties','cm:name'])

savic_prvoslav
Champ on-the-rise
Champ on-the-rise
?sort_by('type',['properties','cm:name']) sorry