I have product index at solr, product has category field and I need to select one product (better would be random) from each category, how query would look like?
Asked
Active
Viewed 233 times
1 Answers
4
if you are looking for sql group by feature,
with solr 3.3 on-wards,
it has the similar feature called FieldCollapsing
Field Collapsing collapses a group of results with the same field value down to a single (or fixed number) of entries. For example, most search engines such as Google collapse on site so only one or two entries are shown, along with a link to click to see more results from that site. Field collapsing can also be used to suppress duplicate documents.

ajreal
- 46,720
- 11
- 89
- 119
-
I will just add regarding random - there's random type in solr, that helps to bring random results: http://lucene.apache.org/solr/api/org/apache/solr/schema/RandomSortField.html – Giedrius Aug 17 '11 at 11:38
-
FieldCollapsing is not released in all recent versions of solr, please find more info here http://stackoverflow.com/questions/6455882/solr-field-collapsing and or course http://wiki.apache.org/solr/FieldCollapsing – Garytxo Aug 22 '11 at 07:42