You are viewing a plain text version of this content. The canonical link for it is here.
Posted to solr-user@lucene.apache.org by "prakash.balaji" <pr...@gmail.com> on 2012/03/30 22:47:51 UTC

Sorting each group using different fields

We have one single query which returns products belonging to multiple
subcategories, we group the products by subcategory, the requirement we have
now is that we need to sort the products in each subcategory using its own
sort order. We can't use single field to sort because a same product could
be available in multiple subcategories. There is an example below to explain
our use case, any help would be much appreciated.

Jeans
   skinny - P1, P2 , P3
   bootcut - P3,P4,P5

if you see we have P3 shared between both subcategories but it appears last
on skinny and first on bootcut.

What we have is a dynamic sort order on each product

P1 - skinny_sort_order = 1
P2 - skinny_sort_order = 2
P3 - skinny_sort_order = 3, bootcut_sort_order = 1
P4 - bootcut_sort_order = 2
P5 - bootcut_sort_order = 3

group.query={cateogory:skinny}&group.sort=skinny_sort_order&group.query={category:bootcut}&group.sort=bootcut_sort_order 

is not giving us the result as it is trying to sort on a combination field
of 2 sort orders. 

Running this as separate queries will solve the issue but we would be firing
n queries depending on as many subcategories we have. Moreover multiple
queries is out of option for us because we retrieve facet information as
part of this query because this query looks at all the document on the
resultset.

Thanks,
Prakash



--
View this message in context: http://lucene.472066.n3.nabble.com/Sorting-each-group-using-different-fields-tp3871997p3871997.html
Sent from the Solr - User mailing list archive at Nabble.com.