Here is how i have previously used grouping. Note i am using Solr 3.5:

SolrQuery query = new SolrQuery("");
query.setRows(GROUPING_LIMIT);
query.setParam("group", Boolean.TRUE);
query.setParam("group.field", "GROUP_FIELD");

This seems to work for me.



On Fri, Nov 30, 2012 at 1:17 PM, Roman Slavík <slaav...@gmail.com> wrote:

> Hi guys,
>
> I have problem with grouping in Solr 4.0 using Solrj api. I need this:
> search some documents limited with solr query, group them by one field and
> return total count of groups.
> There is param 'group.ngroups' for adding groups count into group
> response. Sounds easy, so I wrote something like this:
>
>         SolrQuery query = new SolrQuery().setQuery(**queryString);
>         query.addField("score");
>
>         query.setParam(GroupParams.**GROUP, true);
>         query.setParam(GroupParams.**GROUP_MAIN, true);
>         query.setParam(GroupParams.**GROUP_FIELD, "group_field");
>         query.setParam(GroupParams.**GROUP_LIMIT, "1");
>         query.setParam(GroupParams.**GROUP_TOTAL_COUNT, true);
>
>         QueryResponse response = solrServer.query(query);
>         // contains found docs
>         GroupResponse groupResponse = response.getGroupResponse(); // null
>
> Search result is ok, QueryResponse contains docs I searched for. But group
> response is always null. Did I miss something, some magic parameter for
> enabling group response?
>
> Thanks for any advice
>
> Roman
>

Reply via email to