8

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.

Prakash
  • 423
  • 2
  • 5
  • 15
  • 2
    From this comment in the (current) SOLR source -- https://github.com/apache/lucene-solr/blob/trunk/solr/core/src/java/org/apache/solr/search/Grouping.java#L295 -- and the surrounding code, it appears that the fact a single sort applies to all groups is an acknowledged limitation that hasn't yet been tackled. If your groups include all results (you're not relying on the sorts to return the right top N), maybe you could get/calculate the other sort values via a pseudo-field, then re-sort before display. Then at least it'd just be one query, returning all the data you need. – gojomo Sep 10 '12 at 06:03

1 Answers1

1

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

phanin
  • 5,327
  • 5
  • 32
  • 50