Please find the resonse and query when grouping and sorting by rank : http://localhost:8983/solr/master_shaneco_Product_flip/select?indent=on&q=rank:[1%20TO%20*]&wt=json&group=true&group.main=true&group.field=rank&rows=50&fl=code_String,price,rank&sort=rank+asc&group.limit=3 { "responseHeader":{ "status":0, "QTime":5, "params":{ "q":"rank:[1 TO *]", "group.main":"true", "indent":"on", "fl":"code_String,price,rank", "group.limit":"3", "sort":"rank asc", "rows":"50", "wt":"json", "group.field":"rank", "group":"true"}}, "response":{"numFound":14640,"start":0,"docs":[ { "price":4120.0, "rank":1}, { "price":4210.0, "rank":1}, { "price":4185.0, "rank":1}, { "price":4225.0, "rank":2}, { "price":4270.0, "rank":2}, { "price":4270.0, "rank":2}, { "price":2230.0, "rank":3}, { "price":2110.0, "rank":3}, { "price":2110.0, "rank":3}, { "price":1910.0, "rank":4}, { "price":2175.0, "rank":4}, { "price":2045.0, "rank":4}, { "price":4830.0, "rank":5}, { "price":4845.0, "rank":5}, { "price":4905.0, "rank":5}, { "price":4180.0, "rank":6}, { "price":4485.0, "rank":6}, { "price":4530.0, "rank":6}, { "price":1340.0, "rank":7}, { "price":3535.0, "rank":7}, { "price":1360.0, "rank":7}, { "price":1275.0, "rank":8}, { "price":1165.0, "rank":8}, { "price":1215.0, "rank":8}, { "price":1080.0, "rank":9}, { "price":1075.0, "rank":9}, { "price":1030.0, "rank":9}, { "price":3310.0, "rank":10}, { "price":4030.0, "rank":10}, { "price":2625.0, "rank":10}, { "price":4140.0, "rank":11}, { "price":4140.0, "rank":11}, { "price":3915.0, "rank":11}, { "price":1670.0, "rank":12}, { "price":1610.0, "rank":12}, { "price":1670.0, "rank":12}, { "price":1530.0, "rank":13}, { "price":1530.0, "rank":13}, { "price":1530.0, "rank":13}, { "price":3945.0, "rank":14}, { "price":3955.0, "rank":14}, { "price":4160.0, "rank":14}, { "price":2045.0, "rank":15}, { "price":2545.0, "rank":15}, { "price":2615.0, "rank":15}, { "price":720.0, "rank":16}, { "price":630.0, "rank":16}, { "price":505.0, "rank":16}, { "price":2835.0, "rank":17}, { "price":2835.0, "rank":17}] }}
Requirement is sort on top of those grouped results based on price. Below is the query i am trying with bit not working. http://localhost:8983/solr/master_shaneco_Product_flip/select?indent=on&q=rank:[1%20TO%20*]&wt=json&group=true&group.main=true&group.field=rank&rows=50&fl=code_String,price,rank&sort=price+asc&group.limit=3 { "responseHeader":{ "status":0, "QTime":4, "params":{ "q":"rank:[1 TO *]", "group.main":"true", "indent":"on", "fl":"code_String,price,rank", "group.limit":"3", "sort":"price asc", "rows":"50", "wt":"json", "group.field":"rank", "group":"true"}}, "response":{"numFound":14640,"start":0,"docs":[ { "price":10.0, "rank":1422}, { "price":10.0, "rank":1422}, { "price":25.0, "rank":1533}, { "price":25.0, "rank":1533}, { "price":35.0, "rank":1533}, { "price":25.0, "rank":1766}, { "price":25.0, "rank":1766}, { "price":35.0, "rank":1868}, { "price":35.0, "rank":1868}, { "price":40.0, "rank":1868}, { "price":40.0, "rank":1779}, { "price":40.0, "rank":1779}, { "price":45.0, "rank":1759}, { "price":45.0, "rank":1759}, { "price":60.0, "rank":1759}, { "price":55.0, "rank":2267}, { "price":55.0, "rank":2267}, { "price":60.0, "rank":1272}, { "price":60.0, "rank":1272}, { "price":65.0, "rank":1272}, { "price":60.0, "rank":2356}, { "price":60.0, "rank":2356}, { "price":60.0, "rank":1366}, { "price":60.0, "rank":1366}, { "price":60.0, "rank":1366}, { "price":65.0, "rank":1190}, { "price":65.0, "rank":1190}, { "price":65.0, "rank":1190}, { "price":65.0, "rank":2182}, { "price":65.0, "rank":2182}, { "price":75.0, "rank":2182}, { "price":70.0, "rank":2253}, { "price":70.0, "rank":2253}, { "price":75.0, "rank":2253}, { "price":70.0, "rank":2051}, { "price":70.0, "rank":2051}, { "price":70.0, "rank":2051}, { "price":75.0, "rank":2219}, { "price":75.0, "rank":2219}, { "price":75.0, "rank":2435}, { "price":75.0, "rank":2435}, { "price":80.0, "rank":2435}, { "price":75.0, "rank":1637}, { "price":75.0, "rank":1637}, { "price":75.0, "rank":2214}, { "price":75.0, "rank":2214}, { "price":95.0, "rank":2214}, { "price":80.0, "rank":1375}, { "price":80.0, "rank":1375}, { "price":90.0, "rank":1375}] }} Thanks for your time. Thanks, Venkat. On Tue, Sep 11, 2018 at 10:04 AM Erick Erickson <erickerick...@gmail.com> wrote: > This is still confusing: > > bq. But the requirement is to sort on all the results we show to the > customer. > > What does grouping have to do with that statement? Would it be served > by just _not_ grouping at all? If not, why not? > > Please provide a small set of example documents and what you want to > show in the two cases. > > Best, > Erick > On Mon, Sep 10, 2018 at 6:52 PM Venkateswarlu Bommineni > <bvr...@gmail.com> wrote: > > > > Hello Erik, > > > > Sorry for the confustion . here is the scenario. > > > > We have 2 fields rank,price for each product. multiple products may have > > same rank but different prices. > > > > So on products listing page, by default we will group on rank and show 3 > > products for each group and sort based on Rank. > > > > But Customers can sort on price too. If they do sorting on price then > > sorting is happening inside group instead of all the records. > > > > But the requirement is to sort on all the results we show to the > customer. > > > > > > Query for grouping : > > > https://localhost/solr/master_shaneco_Product_flip/select?indent=on&q=rank:[1%20TO%20*]&wt=json&group=true&group.limit=3&group.main=true&group.field=rank&rows=50&sort=rank+desc > > > > Query when customer click on sort by price: > > > > > https://localhost/solr/master_shaneco_Product_flip/select?indent=on&q=rank:[1%20TO%20*]&wt=json&group=true&group.limit=3&group.main=true&group.field=rank&rows=50&sort=price+desc > > > > > > Thanks, > > Venkat. > > > > On Mon, Sep 10, 2018 at 5:34 PM Erick Erickson <erickerick...@gmail.com> > > wrote: > > > > > bq. I just wanted to know if there is any attribute which says sort on > all > > > the > > > document list instead of relative to group results. > > > > > > I really don't know what you want here. "sort on all the document list" > > > seems > > > like just sorting without grouping. > > > > > > From that problem statement I don't see what grouping has to do with > > > anything. > > > > > > Perhaps if you gave a concrete example of documents and the return you > > > expect we could understand your use-case better. > > > > > > Best, > > > Erick > > > On Mon, Sep 10, 2018 at 3:03 PM Venkateswarlu Bommineni > > > <bvr...@gmail.com> wrote: > > > > > > > > Thanks for the reply Shawn. > > > > > > > > I have tried multiple combination of group.sort and sort but non of > them > > > > worked. > > > > > > > > I just wanted to know if there is any attribute which says sort on > all > > > the > > > > document list instead of relative to group results. > > > > > > > > Can you please help if you have any idea or work around ? > > > > > > > > Thanks, > > > > Venakt. > > > > > > > > On Sat, Sep 8, 2018 at 8:40 PM Shawn Heisey <apa...@elyograg.org> > wrote: > > > > > > > > > On 9/8/2018 8:34 PM, Venkateswarlu Bommineni wrote: > > > > > > Query ; > > > > > > https:// > > > > > > > > > <hostname>/solr/default/select?fq=rank_int:[1%20TO%20*]&indent=on&wt=json&group=true&group.main=true&group.field= > > > > > > > > > > > > > > > rank_int&group.limit=3&q=*&fl=code_string,sapRank_int,price&sort=price+desc > > > > > > > > > > > > I am grouping on field *rank_int with group limit>3 and doing the > > > sorting > > > > > > on price. sorting is happening inside the group not on whole > > > records.* > > > > > > > > > > You need to find the right combination of sort and group.sort > > > parameters. > > > > > > > > > > > > > > > > > > > https://lucene.apache.org/solr/guide/6_6/result-grouping.html#ResultGrouping-RequestParameters > > > > > > > > > > Thanks, > > > > > Shawn > > > > > > > > > > > > > >