sunskin
sunskin

Reputation: 1680

Sort a facet field by index not count in Solr

I am trying to sort a facet field by 'index' and not by default 'count'. http://wiki.apache.org/solr/SimpleFacetParameters#facet.sort

I have facet fields such as Date, Places, Keywords. By default, all the three facet fields are sorted by 'count'. I am interested in changing just the sort on 'Date' to 'index' and not default 'count'. Is there anything that I can do in solrconfig?

Upvotes: 2

Views: 6153

Answers (1)

Ion Cojocaru
Ion Cojocaru

Reputation: 2583

It's set to count by default, but can be customized per field basis. Based on this, you need to set it to index for all and for the rest of fields set it to count.

Example query params: ...&facet.field=Date&facet.field=Keywords&facet.field=Places&facet.sort=index&f.Place.facet.sort=count&f.Keywords.facet.sort=count

EDIT: My understanding is that index doesn't mean alphabetical. It means the natural order of terms in the index. I am not sure if there is a way to do it at the query time, but if you can rebuild your index you can prefix your data e.g. 23_date1, 24_date2 where date1 > date2 for descending. At the client side just display without the prefix as suggested here.

Upvotes: 2

Related Questions