How to make Solr query returning results grouped by field -
i channel solr search results @ query time. example have 3 channels: products
, faq
, other_docs
. within same solr core same fields filled. acceive have solr group results "channel" me.
sample database (csv):
id,channel,name,desc 1,product,some product,this cool product! 2,product,other product,this other product! 3,faq,how stuff,this time: it! 4,other_docs,legal notice,all base belong 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 cool product!</str></doc> <doc> <str name="name">other product</str> <str name="desc">this other product!</str></doc> </result> </lst> <lst> <str name="groupvalue">faq</str> <result name="doclist" numfound="1" start="0"> <doc> <str name="name">how stuff</str> <str name="desc">this time: it!</str></doc> </result> </lst> </arr> </lst> </lst> </response>
how acceive this?
check field collapsing feature in solr
Comments
Post a Comment