Reputation: 3480
I like to channel Solr search results at query time. For example I have three channels: products
, faq
and other_docs
. All within the same Solr core with the same fields filled. What I would like to acceive is to have Solr group the results "channel" for me.
Sample database (csv):
id,channel,name,desc
1,product,Some product,This is an very cool product!
2,product,Other product,This is an other product!
3,faq,How to stuff,This time: Simply do it!
4,other_docs,Legal notice,All your base are belong to us!
Wanted query result (xml):
<?xml version="1.0" encoding="UTF-8"?>
<response>
<lst name="grouped">
<lst name="channel">
<int name="matches">3</int>
<arr name="groups">
<lst>
<str name="groupValue">product</str>
<result name="doclist" numFound="2" start="0">
<doc>
<str name="name">Some product</str>
<str name="desc">This is an very cool product!</str></doc>
<doc>
<str name="name">Other product</str>
<str name="desc">This is an other product!</str></doc>
</result>
</lst>
<lst>
<str name="groupValue">faq</str>
<result name="doclist" numFound="1" start="0">
<doc>
<str name="name">How to stuff</str>
<str name="desc">This time: Simply do it!</str></doc>
</result>
</lst>
</arr>
</lst>
</lst>
</response>
How do I acceive this?
Upvotes: 0
Views: 1468
Reputation: 15244
Check Field collapsing feature in SOLR
Result Grouping / Field Collapsing
Upvotes: 1