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 Omri Cohen <om...@gmail.com> on 2011/08/14 16:53:06 UTC

Results Group-By using SolrJ

Hi All,

I am trying to group by results using SolrJ. According to
https://issues.apache.org/jira/browse/SOLR-2637 the feature was added, so I
upgraded to SolrJ-3.4-Snapshot and I can see the necessary method for
grouping in QueryResponse, which is getGroupResponse(). The only thing left
that I don't understand is where do I set on which field to group. There is
no method that looks like it does so on the SolrQuery object..

Ideas anyone ?

thanks,
Omri

Re: Results Group-By using SolrJ

Posted by Omri Cohen <om...@gmail.com>.
Thanks a lot!! Exactly what I was looking for..

That solved this!
On Sun, Aug 14, 2011 at 6:23 PM, Martijn v Groningen <
martijn.v.groningen@gmail.com> wrote:

> Hi Omri,
>
> SOLR-2637 was concerned with adding grouped response parsing. There is no
> convenience method for grouping, but you can use the normal
> SolrQuery#set(...) methods to enable grouping.
> The following code should enable grouping via SolrJ api:
> SolrQuery query = new SolrQuery();
> query.set(GroupParams.GROUP, true);
> query.set(GroupParams.GROUP_FIELD, "your_field");
>
> Martijn
>
> On 14 August 2011 16:53, Omri Cohen <om...@gmail.com> wrote:
>
> > Hi All,
> >
> > I am trying to group by results using SolrJ. According to
> > https://issues.apache.org/jira/browse/SOLR-2637 the feature was added,
> so
> > I
> > upgraded to SolrJ-3.4-Snapshot and I can see the necessary method for
> > grouping in QueryResponse, which is getGroupResponse(). The only thing
> left
> > that I don't understand is where do I set on which field to group. There
> is
> > no method that looks like it does so on the SolrQuery object..
> >
> > Ideas anyone ?
> >
> > thanks,
> > Omri
> >
>
>
>
> --
> Met vriendelijke groet,
>
> Martijn van Groningen
>

Re: Results Group-By using SolrJ

Posted by Martijn v Groningen <ma...@gmail.com>.
Hi Omri,

SOLR-2637 was concerned with adding grouped response parsing. There is no
convenience method for grouping, but you can use the normal
SolrQuery#set(...) methods to enable grouping.
The following code should enable grouping via SolrJ api:
SolrQuery query = new SolrQuery();
query.set(GroupParams.GROUP, true);
query.set(GroupParams.GROUP_FIELD, "your_field");

Martijn

On 14 August 2011 16:53, Omri Cohen <om...@gmail.com> wrote:

> Hi All,
>
> I am trying to group by results using SolrJ. According to
> https://issues.apache.org/jira/browse/SOLR-2637 the feature was added, so
> I
> upgraded to SolrJ-3.4-Snapshot and I can see the necessary method for
> grouping in QueryResponse, which is getGroupResponse(). The only thing left
> that I don't understand is where do I set on which field to group. There is
> no method that looks like it does so on the SolrQuery object..
>
> Ideas anyone ?
>
> thanks,
> Omri
>



-- 
Met vriendelijke groet,

Martijn van Groningen