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 Tomasz Kępski <to...@kepski.pl> on 2009/11/24 15:19:30 UTC
Get one document from each category
Hi,
I have the following case:
In my index I do have documents categorized (category_id - int sortable
field). I would like to get three top documents matching user query BUT
each have to be from different category.:
for example from returned set (doc_id : category id):
1:1
2:1
3:1
4:2
5:1
6:2
7:3
8:4
I would like to get docs 1, 4 and 7.
Is that possible without quering 3 times? Often lot of (more than my
limit) the docs at the beginning are from the same category.
I'm using PHP Apache Solr so I would like to avoid processing large sets
of data in my PHP based application.
Tomek
Re: Get one document from each category
Posted by Andrey Klochkov <ak...@griddynamics.com>.
Hi
I think you need field collapsing, look here
http://wiki.apache.org/solr/FieldCollapsing
2009/11/24 Tomasz Kępski <to...@kepski.pl>
> Hi,
>
> I have the following case:
>
> In my index I do have documents categorized (category_id - int sortable
> field). I would like to get three top documents matching user query BUT each
> have to be from different category.:
>
> for example from returned set (doc_id : category id):
>
> 1:1
> 2:1
> 3:1
> 4:2
> 5:1
> 6:2
> 7:3
> 8:4
>
> I would like to get docs 1, 4 and 7.
> Is that possible without quering 3 times? Often lot of (more than my limit)
> the docs at the beginning are from the same category.
> I'm using PHP Apache Solr so I would like to avoid processing large sets of
> data in my PHP based application.
>
> Tomek
>
--
Andrew Klochkov
Senior Software Engineer,
Grid Dynamics