group.limit>1 and sorting is not working as expected

classic Classic list List threaded Threaded
12 messages Options
Reply | Threaded
Open this post in threaded view
|

group.limit>1 and sorting is not working as expected

Venkateswarlu Bommineni
Hello Solr Experts,

I am facing an weird issue. where if i have put group.limit>1 then sorting
is not working as expected.

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.*

*but if i put group.limit=1 then sorting is working absolutely fine.*

Could you please help me , how can i sort on all the results with
group.limit>1.

*Thanks,*
*Venkat. *



Thanks,
Venkat.
Reply | Threaded
Open this post in threaded view
|

Re: group.limit>1 and sorting is not working as expected

Shawn Heisey-2
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

Reply | Threaded
Open this post in threaded view
|

Re: group.limit>1 and sorting is not working as expected

Venkateswarlu Bommineni
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 <[hidden email]> 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
>
>
Reply | Threaded
Open this post in threaded view
|

Re: group.limit>1 and sorting is not working as expected

Erick Erickson
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
<[hidden email]> 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 <[hidden email]> 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
> >
> >
Reply | Threaded
Open this post in threaded view
|

Re: group.limit>1 and sorting is not working as expected

Venkateswarlu Bommineni
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 <[hidden email]>
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
> <[hidden email]> 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 <[hidden email]> 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
> > >
> > >
>
Reply | Threaded
Open this post in threaded view
|

Re: group.limit>1 and sorting is not working as expected

Erick Erickson
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
<[hidden email]> 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 <[hidden email]>
> 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
> > <[hidden email]> 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 <[hidden email]> 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
> > > >
> > > >
> >
Reply | Threaded
Open this post in threaded view
|

Re: group.limit>1 and sorting is not working as expected

Venkateswarlu Bommineni
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 <[hidden email]>
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
> <[hidden email]> 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 <[hidden email]>
> > 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
> > > <[hidden email]> 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 <[hidden email]>
> 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
> > > > >
> > > > >
> > >
>
Reply | Threaded
Open this post in threaded view
|

Re: group.limit>1 and sorting is not working as expected

Shawn Heisey-2
On 9/11/2018 10:14 AM, Venkateswarlu Bommineni wrote:
> Please find the resonse and query when grouping and sorting by rank :

I see no evidence of grouping happening in either of those responses. 
They look like standard responses do when grouping is not enabled.

Here's an example of a grouped result from the techproducts example that
ships with Solr.  The "response" section is gone and has been replaced
by a "grouped" section:

|{ "responseHeader":{ "status":0, "QTime":0, "params":{ "q":"*:*",
"fl":"id,manu,price", "group.limit":"3", "group.field":"manu",
"_":"1536686115965", "group":"true"}}, "grouped":{ "manu":{
"matches":32, "groups":[{ "groupValue":null,
"doclist":{"numFound":12,"start":0,"docs":[ { "id":"GB18030TEST",
"price":0.0}, { "id":"adata"}, { "id":"apple"}] }}, {
"groupValue":"Samsung Electronics Co. Ltd.",
"doclist":{"numFound":1,"start":0,"docs":[ { "id":"SP2514N",
"manu":"Samsung Electronics Co. Ltd.", "price":92.0}] }}, {
"groupValue":"Maxtor Corp.", "doclist":{"numFound":1,"start":0,"docs":[
{ "id":"6H500F0", "manu":"Maxtor Corp.", "price":350.0}] }}, {
"groupValue":"Belkin", "doclist":{"numFound":2,"start":0,"docs":[ {
"id":"F8V7067-APL-KIT", "manu":"Belkin", "price":19.95}, { "id":"IW-02",
"manu":"Belkin", "price":11.5}] }}, { "groupValue":"Apple Computer
Inc.", "doclist":{"numFound":1,"start":0,"docs":[ { "id":"MA147LL/A",
"manu":"Apple Computer Inc.", "price":399.0}] }}, {
"groupValue":"Corsair Microsystems Inc.",
"doclist":{"numFound":2,"start":0,"docs":[ { "id":"TWINX2048-3200PRO",
"manu":"Corsair Microsystems Inc.", "price":185.0}, { "id":"VS1GB400C3",
"manu":"Corsair Microsystems Inc.", "price":74.99}] }}, {
"groupValue":"A-DATA Technology Inc.",
"doclist":{"numFound":1,"start":0,"docs":[ { "id":"VDBDB1A16",
"manu":"A-DATA Technology Inc."}] }}, { "groupValue":"Bank of America",
"doclist":{"numFound":1,"start":0,"docs":[ { "id":"USD", "manu":"Bank of
America"}] }}, { "groupValue":"European Union",
"doclist":{"numFound":1,"start":0,"docs":[ { "id":"EUR",
"manu":"European Union"}] }}, { "groupValue":"U.K.",
"doclist":{"numFound":1,"start":0,"docs":[ { "id":"GBP", "manu":"U.K."}]
}}]}}} ||Thanks,||Shawn|

||||
Reply | Threaded
Open this post in threaded view
|

Re: group.limit>1 and sorting is not working as expected

Erick Erickson
How this all works will be much clearer if you don't use "group.main=true"

But you still haven't _shown_ us what you _expect_.

In the second query, Solr is doing exactly what you're telling it to.
Return groups of up to three docs lowest-priced docs in each group and
ordering the groups by the lowest price doc appearing in the group.

What I'm guessing you want to do is specify sort=rank asc&group.sort=price asc

Best,
Erick
On Tue, Sep 11, 2018 at 10:23 AM Shawn Heisey <[hidden email]> wrote:

>
> On 9/11/2018 10:14 AM, Venkateswarlu Bommineni wrote:
> > Please find the resonse and query when grouping and sorting by rank :
>
> I see no evidence of grouping happening in either of those responses.
> They look like standard responses do when grouping is not enabled.
>
> Here's an example of a grouped result from the techproducts example that
> ships with Solr.  The "response" section is gone and has been replaced
> by a "grouped" section:
>
> |{ "responseHeader":{ "status":0, "QTime":0, "params":{ "q":"*:*",
> "fl":"id,manu,price", "group.limit":"3", "group.field":"manu",
> "_":"1536686115965", "group":"true"}}, "grouped":{ "manu":{
> "matches":32, "groups":[{ "groupValue":null,
> "doclist":{"numFound":12,"start":0,"docs":[ { "id":"GB18030TEST",
> "price":0.0}, { "id":"adata"}, { "id":"apple"}] }}, {
> "groupValue":"Samsung Electronics Co. Ltd.",
> "doclist":{"numFound":1,"start":0,"docs":[ { "id":"SP2514N",
> "manu":"Samsung Electronics Co. Ltd.", "price":92.0}] }}, {
> "groupValue":"Maxtor Corp.", "doclist":{"numFound":1,"start":0,"docs":[
> { "id":"6H500F0", "manu":"Maxtor Corp.", "price":350.0}] }}, {
> "groupValue":"Belkin", "doclist":{"numFound":2,"start":0,"docs":[ {
> "id":"F8V7067-APL-KIT", "manu":"Belkin", "price":19.95}, { "id":"IW-02",
> "manu":"Belkin", "price":11.5}] }}, { "groupValue":"Apple Computer
> Inc.", "doclist":{"numFound":1,"start":0,"docs":[ { "id":"MA147LL/A",
> "manu":"Apple Computer Inc.", "price":399.0}] }}, {
> "groupValue":"Corsair Microsystems Inc.",
> "doclist":{"numFound":2,"start":0,"docs":[ { "id":"TWINX2048-3200PRO",
> "manu":"Corsair Microsystems Inc.", "price":185.0}, { "id":"VS1GB400C3",
> "manu":"Corsair Microsystems Inc.", "price":74.99}] }}, {
> "groupValue":"A-DATA Technology Inc.",
> "doclist":{"numFound":1,"start":0,"docs":[ { "id":"VDBDB1A16",
> "manu":"A-DATA Technology Inc."}] }}, { "groupValue":"Bank of America",
> "doclist":{"numFound":1,"start":0,"docs":[ { "id":"USD", "manu":"Bank of
> America"}] }}, { "groupValue":"European Union",
> "doclist":{"numFound":1,"start":0,"docs":[ { "id":"EUR",
> "manu":"European Union"}] }}, { "groupValue":"U.K.",
> "doclist":{"numFound":1,"start":0,"docs":[ { "id":"GBP", "manu":"U.K."}]
> }}]}}} ||Thanks,||Shawn|
>
> ||||
Reply | Threaded
Open this post in threaded view
|

Re: group.limit>1 and sorting is not working as expected

Venkateswarlu Bommineni
Erik and Shawn,

Sorry for the confusion.

Yes Solr is sorting inside the grouped results.but not on all the results.
Example : we have got 6 records by solr response. if i do *sort=price desc
, it is sorting indise each group.*

*But the requirement is to sort on all the results.*

*Current results :*

"matches":14640,
      "groups":[{
          "groupValue":446,
          "doclist":{"numFound":4,"start":0,"docs":[
              {
                "price":32015.0,
                "rank":446},
              {
                "price":32015.0,
                "rank":446},
              {
                "price":*30670.0,*
                "rank":446}]
          }},
        {
          "groupValue":436,
          "doclist":{"numFound":4,"start":0,"docs":[
              {
                "price":*31000.0,*
                "rank":436},
              {
                "price":29040.0,
                "rank":436},
              {
                "price":27775.0,
                "rank":436}]
          }},
        {


What i am expecting is (it might be silly) if i put group.main=true and
sort by price then the results are:

      {
        "priceValueGLP_usd_double":32015.0,
        "sapRank_int":446},
      {
        "priceValueGLP_usd_double":32015.0,
        "sapRank_int":446},
      {
        "priceValueGLP_usd_double":*31000.0*,
        "sapRank_int":445},
      {
        "priceValueGLP_usd_double":*30670.0*,
        "sapRank_int":446},
      {
        "priceValueGLP_usd_double":29040.0,
        "sapRank_int":436},
      {
        "priceValueGLP_usd_double":27775.0,
        "sapRank_int":436},


Sorry if it did not make sense. and suggest if there is any way we can
achieve that.



Thanks,
Venkat.





On Tue, Sep 11, 2018 at 11:37 AM Erick Erickson <[hidden email]>
wrote:

> How this all works will be much clearer if you don't use "group.main=true"
>
> But you still haven't _shown_ us what you _expect_.
>
> In the second query, Solr is doing exactly what you're telling it to.
> Return groups of up to three docs lowest-priced docs in each group and
> ordering the groups by the lowest price doc appearing in the group.
>
> What I'm guessing you want to do is specify sort=rank asc&group.sort=price
> asc
>
> Best,
> Erick
> On Tue, Sep 11, 2018 at 10:23 AM Shawn Heisey <[hidden email]> wrote:
> >
> > On 9/11/2018 10:14 AM, Venkateswarlu Bommineni wrote:
> > > Please find the resonse and query when grouping and sorting by rank :
> >
> > I see no evidence of grouping happening in either of those responses.
> > They look like standard responses do when grouping is not enabled.
> >
> > Here's an example of a grouped result from the techproducts example that
> > ships with Solr.  The "response" section is gone and has been replaced
> > by a "grouped" section:
> >
> > |{ "responseHeader":{ "status":0, "QTime":0, "params":{ "q":"*:*",
> > "fl":"id,manu,price", "group.limit":"3", "group.field":"manu",
> > "_":"1536686115965", "group":"true"}}, "grouped":{ "manu":{
> > "matches":32, "groups":[{ "groupValue":null,
> > "doclist":{"numFound":12,"start":0,"docs":[ { "id":"GB18030TEST",
> > "price":0.0}, { "id":"adata"}, { "id":"apple"}] }}, {
> > "groupValue":"Samsung Electronics Co. Ltd.",
> > "doclist":{"numFound":1,"start":0,"docs":[ { "id":"SP2514N",
> > "manu":"Samsung Electronics Co. Ltd.", "price":92.0}] }}, {
> > "groupValue":"Maxtor Corp.", "doclist":{"numFound":1,"start":0,"docs":[
> > { "id":"6H500F0", "manu":"Maxtor Corp.", "price":350.0}] }}, {
> > "groupValue":"Belkin", "doclist":{"numFound":2,"start":0,"docs":[ {
> > "id":"F8V7067-APL-KIT", "manu":"Belkin", "price":19.95}, { "id":"IW-02",
> > "manu":"Belkin", "price":11.5}] }}, { "groupValue":"Apple Computer
> > Inc.", "doclist":{"numFound":1,"start":0,"docs":[ { "id":"MA147LL/A",
> > "manu":"Apple Computer Inc.", "price":399.0}] }}, {
> > "groupValue":"Corsair Microsystems Inc.",
> > "doclist":{"numFound":2,"start":0,"docs":[ { "id":"TWINX2048-3200PRO",
> > "manu":"Corsair Microsystems Inc.", "price":185.0}, { "id":"VS1GB400C3",
> > "manu":"Corsair Microsystems Inc.", "price":74.99}] }}, {
> > "groupValue":"A-DATA Technology Inc.",
> > "doclist":{"numFound":1,"start":0,"docs":[ { "id":"VDBDB1A16",
> > "manu":"A-DATA Technology Inc."}] }}, { "groupValue":"Bank of America",
> > "doclist":{"numFound":1,"start":0,"docs":[ { "id":"USD", "manu":"Bank of
> > America"}] }}, { "groupValue":"European Union",
> > "doclist":{"numFound":1,"start":0,"docs":[ { "id":"EUR",
> > "manu":"European Union"}] }}, { "groupValue":"U.K.",
> > "doclist":{"numFound":1,"start":0,"docs":[ { "id":"GBP", "manu":"U.K."}]
> > }}]}}} ||Thanks,||Shawn|
> >
> > ||||
>
Reply | Threaded
Open this post in threaded view
|

Re: group.limit>1 and sorting is not working as expected

Shawn Heisey-2
On 9/11/2018 12:00 PM, Venkateswarlu Bommineni wrote:

> What i am expecting is (it might be silly) if i put group.main=true and
> sort by price then the results are:
>
>        {
>          "priceValueGLP_usd_double":32015.0,
>          "sapRank_int":446},
>        {
>          "priceValueGLP_usd_double":32015.0,
>          "sapRank_int":446},
>        {
>          "priceValueGLP_usd_double":*31000.0*,
>          "sapRank_int":445},
>        {
>          "priceValueGLP_usd_double":*30670.0*,
>          "sapRank_int":446},
>        {
>          "priceValueGLP_usd_double":29040.0,
>          "sapRank_int":436},
>        {
>          "priceValueGLP_usd_double":27775.0,
>          "sapRank_int":436},

It sounds like you don't want grouping at all.  That seems to be a
result list sorted by price.  If you group by rank, then all of the
results for a specific rank will be together, and the response you
indicated above where the docs with rank 446 are not all together will
be impossible.  If you remove the grouping, then you can get a simple
result sorted by price.

Thanks,
Shawn

Reply | Threaded
Open this post in threaded view
|

Re: group.limit>1 and sorting is not working as expected

Erick Erickson
OK, you just don't want to group as Shawn says. The group.main=true
just flattens the list but still returns the docs in groups does all
the work of grouping. So instead of getting
value=1 [
   doc31
   doc64
 ]
value=2 [
   doc 98
   doc 6
  ]

you get

doc31
doc64
doc98
doc6

Best,
Erick
On Tue, Sep 11, 2018 at 11:48 AM Shawn Heisey <[hidden email]> wrote:

>
> On 9/11/2018 12:00 PM, Venkateswarlu Bommineni wrote:
> > What i am expecting is (it might be silly) if i put group.main=true and
> > sort by price then the results are:
> >
> >        {
> >          "priceValueGLP_usd_double":32015.0,
> >          "sapRank_int":446},
> >        {
> >          "priceValueGLP_usd_double":32015.0,
> >          "sapRank_int":446},
> >        {
> >          "priceValueGLP_usd_double":*31000.0*,
> >          "sapRank_int":445},
> >        {
> >          "priceValueGLP_usd_double":*30670.0*,
> >          "sapRank_int":446},
> >        {
> >          "priceValueGLP_usd_double":29040.0,
> >          "sapRank_int":436},
> >        {
> >          "priceValueGLP_usd_double":27775.0,
> >          "sapRank_int":436},
>
> It sounds like you don't want grouping at all.  That seems to be a
> result list sorted by price.  If you group by rank, then all of the
> results for a specific rank will be together, and the response you
> indicated above where the docs with rank 446 are not all together will
> be impossible.  If you remove the grouping, then you can get a simple
> result sorted by price.
>
> Thanks,
> Shawn
>