Skimming this, I two options come to mind: 1> Simply apply primary, secondary, etc sorts. Something like &sort=subcategory asc,markdown_or_regular desc,sort_order asc
2> You could also use grouping to arrange things in groups and sort within those groups. This has the advantage of returning some members of each of the top N groups in the result set, which makes it easier to get some of each group rather than having to analyze the whole list.... But your example is somewhat contradictory. You say "products which are on markdown, are at the bottom of the documents list" But in your examples, products on "markdown" are intermingled.... Best Erick On Sun, Jun 10, 2012 at 3:36 AM, roz dev <rozde...@gmail.com> wrote: > Hi All > >> >> I have an index which contains a Catalog of Products and Categories, with >> Solr 4.0 from trunk >> >> Data is organized like this: >> >> Category: Books >> >> Sub Category: Programming >> >> Products: >> >> Product # 1, Price: Regular Sort Order:1 >> Product # 2, Price: Markdown, Sort Order:2 >> Product # 3 Price: Regular, Sort Order:3 >> Product # 4 Price: Regular, Sort Order:4 >> .... >> ..... >> ... >> Product # 100 Price: Regular, Sort Order:100 >> >> Sub Category: Fiction >> >> Products: >> >> Product # 1, Price: Markdown, Sort Order:1 >> Product # 2, Price: Regular, Sort Order:2 >> Product # 3 Price: Regular, Sort Order:3 >> Product # 4 Price: Markdown, Sort Order:4 >> .... >> ..... >> ... >> Product # 70 Price: Regular, Sort Order:70 >> >> >> I want to query Solr and sort these products within each of the >> sub-category in a such a way that products which are on markdown, are at >> the bottom of the documents list and other products >> which are on regular price, are sorted as per their sort order in their >> sub-category. >> >> Expected Results are >> >> Category: Books >> >> Sub Category: Programming >> >> Products: >> >> Product # 1, Price: Regular Sort Order:1 >> Product # 2, Price: Markdown, Sort Order:101 >> Product # 3 Price: Regular, Sort Order:3 >> Product # 4 Price: Regular, Sort Order:4 >> .... >> ..... >> ... >> Product # 100 Price: Regular, Sort Order:100 >> >> Sub Category: Fiction >> >> Products: >> >> Product # 1, Price: Markdown, Sort Order:71 >> Product # 2, Price: Regular, Sort Order:2 >> Product # 3 Price: Regular, Sort Order:3 >> Product # 4 Price: Markdown, Sort Order:71 >> .... >> ..... >> ... >> Product # 70 Price: Regular, Sort Order:70 >> >> >> My query is like this: >> >> q=*:*&fq=category:Books >> >> What are the options to implement custom sorting and how do I do it? >> >> >> - Define a Custom Function query? >> - Define a Custom Comparator? Or, >> - Define a Custom Collector? >> >> >> Please let me know the best way to go about it and any pointers to >> customize Solr 4. >> > > Thanks > Saroj