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 Roman Slavík <sl...@effectiva.cz> on 2012/08/23 08:23:48 UTC

Group count in SOLR 3.3

Hi guys,

we are using SOLR 3.3 with Solrj inside our java project. In actual 
version we had to add some grouping support, so we add parameters into 
SolrQuery object like this:

         query.setParam(GroupParams.GROUP, true);
         query.setParam(GroupParams.GROUP_MAIN, true);
         query.setParam(GroupParams.GROUP_FIELD, OUR_GROUP_FIELD);

and we get QueryResponse with results we need. Awesome!

But now I have one remaining problem, I don't know how get number of 
groups from QueryResponse. I found I must add group.ngroups=true param 
into query. So I did it:

        query.setParam(GroupParams.GROUP_TOTAL_COUNT, true);

But QueryResponse seems same. There's no method like "getGroupCount()" 
or group count param in header.

Am I doing something wrong? Or is it SOLR 3.3 problem? If we upgrade to 
newer version, will it works?

Thanks for any advice!

Roman

Re: Group count in SOLR 3.3

Posted by Roman Slavík <sl...@effectiva.cz>.
Thanks, I found GroupResponse was added in Solr 3.4 so I have to update 
version :)

Roman

Dne 24.8.2012 18:09, Erick Erickson napsal(a):
> 3.6 has a getNGroups, does that do what you want?
>
> Best
> Erick
>
> On Thu, Aug 23, 2012 at 2:23 AM, Roman Slavík <sl...@effectiva.cz> wrote:
>> Hi guys,
>>
>> we are using SOLR 3.3 with Solrj inside our java project. In actual version
>> we had to add some grouping support, so we add parameters into SolrQuery
>> object like this:
>>
>>          query.setParam(GroupParams.GROUP, true);
>>          query.setParam(GroupParams.GROUP_MAIN, true);
>>          query.setParam(GroupParams.GROUP_FIELD, OUR_GROUP_FIELD);
>>
>> and we get QueryResponse with results we need. Awesome!
>>
>> But now I have one remaining problem, I don't know how get number of groups
>> from QueryResponse. I found I must add group.ngroups=true param into query.
>> So I did it:
>>
>>         query.setParam(GroupParams.GROUP_TOTAL_COUNT, true);
>>
>> But QueryResponse seems same. There's no method like "getGroupCount()" or
>> group count param in header.
>>
>> Am I doing something wrong? Or is it SOLR 3.3 problem? If we upgrade to
>> newer version, will it works?
>>
>> Thanks for any advice!
>>
>> Roman


Re: Group count in SOLR 3.3

Posted by Erick Erickson <er...@gmail.com>.
3.6 has a getNGroups, does that do what you want?

Best
Erick

On Thu, Aug 23, 2012 at 2:23 AM, Roman Slavík <sl...@effectiva.cz> wrote:
> Hi guys,
>
> we are using SOLR 3.3 with Solrj inside our java project. In actual version
> we had to add some grouping support, so we add parameters into SolrQuery
> object like this:
>
>         query.setParam(GroupParams.GROUP, true);
>         query.setParam(GroupParams.GROUP_MAIN, true);
>         query.setParam(GroupParams.GROUP_FIELD, OUR_GROUP_FIELD);
>
> and we get QueryResponse with results we need. Awesome!
>
> But now I have one remaining problem, I don't know how get number of groups
> from QueryResponse. I found I must add group.ngroups=true param into query.
> So I did it:
>
>        query.setParam(GroupParams.GROUP_TOTAL_COUNT, true);
>
> But QueryResponse seems same. There's no method like "getGroupCount()" or
> group count param in header.
>
> Am I doing something wrong? Or is it SOLR 3.3 problem? If we upgrade to
> newer version, will it works?
>
> Thanks for any advice!
>
> Roman