Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Sort different groups using different sort orders in solr

We are using solr to build an e-commerce application, and we have products getting grouped by subcategory within a parent category. We use dynamic sort order to determine where the product belongs within a subcategory and the same product can appear in more than one subcategory. We are tracking the sort order using dynamic field and each product have multiple sort orders depending on how many subcategory it belongs to. We need to group these products into subcategory and sort it using appropriate sort order. An example below, any help would be greatly appreciated and we are trying to accomplish it using single query.

  • Jeans
    • Bootcut
      • Product1
      • Product2
    • Skinny
      • Product1
      • Product3

Products have following sort order

  • Product1-bootcutSortOrder-10 skinnySortOrder-1
  • Product2-bootcutSortOrder-3
  • Product3-skinnySortOrder-5

Expected result considering the sort order ascending under each group

  • Bootcut
    • Product2
    • Product1
  • Skinny
    • Product1
    • Product3

We want solr to sort each individual group with its sort order - group.query={subcategory:Bootcut}&group.sort=bootcutSortOrder asc&group.query={subcategory:Skinny}&group.sort=skinnySortOrder asc

What solr does is that it sorts on combination of bootCutSortOrder asc, skinnySortOrder asc.

Is it possible in solr to sort the each section of the group with its own sort order?

we are using latest version of solr and are fine with solr 4 as well.

like image 289
Prakash Avatar asked Mar 28 '12 22:03

Prakash


1 Answers

If I understood your explanation correctly, I think your are looking for Faceted Search.

Fortunately, Lucene & Solr support it. You may refer to the following..

Solr Faceted Search

Lucene Faceted Search

Another on Lucene Faceted Search

like image 61
phanin Avatar answered Oct 18 '22 09:10

phanin