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 nish <ni...@gmail.com> on 2013/12/30 08:52:34 UTC

Fetching results with a minimum from each category

I am using solr 4.4.0. The search is performed on products, each of which has
a category field. I want to retrieve top n products. But, if some category
has less than m products among the top n, then I want to retrieve more
products only for those categories.

Eg. I have 4 categories a, b, c, d. n=20 and m=5. Now lets say the top
20(=n) have following category distribution (a:6, b:4, c:6, d:4). Categories
b and d have less than m(=5) products. So I would like to fetch one more
product(with the next highest score) for both these categories.

Is there a way I can do this using solr



--
View this message in context: http://lucene.472066.n3.nabble.com/Fetching-results-with-a-minimum-from-each-category-tp4108659.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Fetching results with a minimum from each category

Posted by nish <ni...@gmail.com>.
Oussama Jilal,

b and d have 4 products in top 20 results obtained and not overall in the
database. Grouping would give me results from all categories, I only want
categories corresponding to top 20 results.

It can be done in 2 solr queries, but it would make the system slow. Was
just wondering if there is a simpler way of doing this.

Thanks



--
View this message in context: http://lucene.472066.n3.nabble.com/Fetching-results-with-a-minimum-from-each-category-tp4108659p4108671.html
Sent from the Solr - User mailing list archive at Nabble.com.

Re: Fetching results with a minimum from each category

Posted by Jilal Oussama <ji...@gmail.com>.
I don't get it, if b and d only have 4 products, how can you fetch one more
for them?

But any way, if you realy know what you are doing, then I can say that this
is quite specific, so you may have to do it in 2 solr queries.

also see the Grouping Componant, it may help you get what you want
(grouping by the category field)

http://wiki.apache.org/solr/FieldCollapsing



2013/12/30 nish <ni...@gmail.com>

> I am using solr 4.4.0. The search is performed on products, each of which
> has
> a category field. I want to retrieve top n products. But, if some category
> has less than m products among the top n, then I want to retrieve more
> products only for those categories.
>
> Eg. I have 4 categories a, b, c, d. n=20 and m=5. Now lets say the top
> 20(=n) have following category distribution (a:6, b:4, c:6, d:4).
> Categories
> b and d have less than m(=5) products. So I would like to fetch one more
> product(with the next highest score) for both these categories.
>
> Is there a way I can do this using solr
>
>
>
> --
> View this message in context:
> http://lucene.472066.n3.nabble.com/Fetching-results-with-a-minimum-from-each-category-tp4108659.html
> Sent from the Solr - User mailing list archive at Nabble.com.
>