7

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.

Krunal
  • 2,967
  • 8
  • 45
  • 101

2 Answers2

9

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.

hooknc
  • 4,854
  • 5
  • 31
  • 60
Jayendra
  • 52,349
  • 4
  • 80
  • 90
  • Thank you for your suggestions. Using this I can offer different order for different field. However, how does it order when we apply order using index? This is not clear. Moreover, I will be interested to know your idea on workaround to implement custom ordering for facet field and facets. Awaiting your response. And thank you once again. – Krunal Sep 04 '13 at 13:45
  • which facet are you referring to ?? are you using facet range for the price ? and want to check for the Ordering of the same ? – Jayendra Sep 05 '13 at 06:26
  • Hi, Yes, I need to keep Price on the first place for all the facets fields. Moreover, also the order of the facets in case of Prices, like you see the changed order in example. – Krunal Sep 05 '13 at 06:29
  • f.price.facet.sort=index|sort should control the range query sort as well. Also the display part can be handled at client side ? Not sure if i got it wrong. – Jayendra Sep 05 '13 at 06:49
  • I'm not getting how to do it on client side.. as facets are ordered from solr. Isn't there anything using which we can ask solr to order it as defined? – Krunal Sep 05 '13 at 13:27
  • Or any other way to implement a custom order? – Krunal Sep 12 '13 at 05:59
0

You can only sort by predefined criteria.

facet.sort is what you use and it can only be: - count - sort the constraints by count (highest count first) - index - to return the constraints sorted in their index order (lexicographic by indexed term). For terms in the ascii range, this will be alphabetically sorted.

Have a look at this: http://wiki.apache.org/solr/SimpleFacetParameters#facet.sort

Maurizio In denmark
  • 4,226
  • 2
  • 30
  • 64
  • Hi, Thank you for your response. I've already looked into this. But we need custom order, where this can't be used somehow. Pls check the example for clearer idea on this. I'm waiting for your advise. – Krunal Sep 04 '13 at 06:31