Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Set Custom Order for Facets coming from Solr

I'm using Solr for offering faceted navigation for e-commerce site. However I need to define the custom order for facets, but I didn't find how to do that in Solr.

Any idea how to do this? I'm using Solr Net and latest version of Solr.

Here is an example what I need to do.

Current Facets

Operating System

  • Android (32)
  • Blackberry OS (8)
  • Windows (6)
  • Apple iOS (6)
  • Bada (5)
  • Proprietary (2)

Price

  • 10001 - 20000 (42)
  • 20001 - 25000 (12)
  • 500 - 5000 (11)
  • 5001 - 10000 (8)

Note that it is just an example. And have many other facets. I want to display Price as the first facet, so need to order this facet field as well as facet options like this.

Price

  • 500 - 5000 (11)
  • 5001 - 10000 (8)
  • 10001 - 20000 (42)
  • 20001 - 25000 (12)

Operating System

  • Android (32)
  • Apple iOS (6)
  • Bada (5)
  • Blackberry OS (8)
  • Proprietary (2)
  • Windows (6)

So here is how I need to order it:

  1. Order Facet Field manually by some way so they are displayed on specific order
  2. Order Facets as per the defined order. For OS, I ordered it alphabetically. Or may be for those facets which doesn't have order defined can be order as default based on number of count in result?

Pls advise.

like image 427
Krunal Avatar asked Sep 02 '13 15:09

Krunal


1 Answers

You can use facet sort per field to order the different facets respectively.

e.g. f.<field_name>.facet.sort=count|index

Solr only provided two options Count and Index sort. Anything else needs to implemented through custom solutions or workarounds.

like image 80
Jayendra Avatar answered Nov 06 '22 17:11

Jayendra