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 entdeveloper <ca...@gmail.com> on 2011/07/13 03:36:06 UTC

Grouping / Collapse Query

I'm messing around with the field collapsing in 4.x
http://wiki.apache.org/solr/FieldCollapsing . Is it currently possible to
group by a field with a certain value only and leave all the others
ungrouped using the group.query param? This currently doesn't seem to work
the way I want it to.

For example, I have documents all with a "type" field. Possible values are:
picture, video, game, other. I want to only group the pictures, and leave
all other documents ungrouped.

If I query something like:
q=dogs&group=true&group.query=type:picture

I ONLY get pictures back. Seems like this behaves more like an 'fq'

What I want is a result set that looks like this:

1. doc 1, type=video
2. doc 2, type=game
3. doc 3, type=picture, + 3 other pictures
4. doc 4, type=video
5. doc 5, type=video
...

I've also tried:
q=dogs&group=true&group.query=type:picture&group.query=-type:video
-type:game

But this doesn't work because the order of the groups don't put together the
correct order of results that would be displayed.

--
View this message in context: http://lucene.472066.n3.nabble.com/Grouping-Collapse-Query-tp3164433p3164433.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Grouping / Collapse Query

Posted by entdeveloper <ca...@gmail.com>.
I guess that's a possible solution, but the two concerns I would have are 1)
putting the burden of sorting on the client instead of solr, where it
belongs. And 2) needing to request more results than I'd want to display in
order to guarantee I could populate the entire page of results to compensate
for the grouping.

--
View this message in context: http://lucene.472066.n3.nabble.com/Grouping-Collapse-Query-tp3164433p3166789.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Grouping / Collapse Query

Posted by Erick Erickson <er...@gmail.com>.
Could you just return the score with the documents, group by type and
order them any way you wanted?

Best
Erick

On Tue, Jul 12, 2011 at 9:36 PM, entdeveloper
<ca...@gmail.com> wrote:
> I'm messing around with the field collapsing in 4.x
> http://wiki.apache.org/solr/FieldCollapsing . Is it currently possible to
> group by a field with a certain value only and leave all the others
> ungrouped using the group.query param? This currently doesn't seem to work
> the way I want it to.
>
> For example, I have documents all with a "type" field. Possible values are:
> picture, video, game, other. I want to only group the pictures, and leave
> all other documents ungrouped.
>
> If I query something like:
> q=dogs&group=true&group.query=type:picture
>
> I ONLY get pictures back. Seems like this behaves more like an 'fq'
>
> What I want is a result set that looks like this:
>
> 1. doc 1, type=video
> 2. doc 2, type=game
> 3. doc 3, type=picture, + 3 other pictures
> 4. doc 4, type=video
> 5. doc 5, type=video
> ...
>
> I've also tried:
> q=dogs&group=true&group.query=type:picture&group.query=-type:video
> -type:game
>
> But this doesn't work because the order of the groups don't put together the
> correct order of results that would be displayed.
>
> --
> View this message in context: http://lucene.472066.n3.nabble.com/Grouping-Collapse-Query-tp3164433p3164433.html
> Sent from the Solr - User mailing list archive at Nabble.com.
>