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 Jeffrey Gelens <je...@buyways.nl> on 2009/05/15 13:42:56 UTC

Documents in facet results

Dear community,

I'm wondering if there is a clean solution to my rather interesting problem. 
The following facet query results in a list of all facets and the number of 
all documents matching the corresponding facet as seen below:

Query:
  <str name="q">*:*</str>
  <str name="facet.limit">5</str>
  <str name="facet.field">en_atmosphere</str>
  <str name="rows">0</str>

Results:
<lst name="facet_counts">
 <lst name="facet_queries"/>
 <lst name="facet_fields">
  <lst name="en_atmosphere">
	<int name="Snug and pleasant">675</int>
	<int name="Authentic">385</int>
	<int name="Modern and functional">378</int>
	<int name="Romantic">374</int>
	<int name="Modest">339</int>
  </lst>
 </lst>

Now I would like to have the documents as child node of the various facet 
fields, so that the result will be something similar as:

<lst name="facet_counts">
 <lst name="facet_queries"/>
 <lst name="facet_fields">
  <lst name="en_atmosphere">
	<docs facet="Snug and pleasant">
		<doc>...
		<doc>...
	</docs>
	<docs facet="Authentic">
		<doc>...
		<doc>...
	</docs>
	...
  </lst>
 </lst>

Of course it would be possible to send a couple of queries for each facet to 
get the corresponding docs or I can parse the response xml, but it would be 
more efficient if SOLR can return the result as above.

Thanks!

-- 
Jeffrey Gelens          Buyways B.V.          Tel. 050 853 6600
Webengineer             Friesestraatweg 215c  Fax. 050 853 6601
http://www.buyways.nl   9743 AD Groningen     KvK  01074105

Re: Documents in facet results

Posted by Fergus McMenemie <fe...@twig.me.uk>.
>Dear community,
>
>I'm wondering if there is a clean solution to my rather interesting problem. 
>The following facet query results in a list of all facets and the number of 
>all documents matching the corresponding facet as seen below:
>

Probably the quickest way would be to write another XSLT transform to reformat
the results to match your requirements. Then add extra query params to call
the transform.

   <str name="wt">xslt</str>
   <str name="tr">reformat.xsl</str>

Fergus.

>Query:
>  <str name="q">*:*</str>
>  <str name="facet.limit">5</str>
>  <str name="facet.field">en_atmosphere</str>
>  <str name="rows">0</str>
>
>Results:
><lst name="facet_counts">
> <lst name="facet_queries"/>
> <lst name="facet_fields">
>  <lst name="en_atmosphere">
>	<int name="Snug and pleasant">675</int>
>	<int name="Authentic">385</int>
>	<int name="Modern and functional">378</int>
>	<int name="Romantic">374</int>
>	<int name="Modest">339</int>
>  </lst>
> </lst>
>
>Now I would like to have the documents as child node of the various facet 
>fields, so that the result will be something similar as:
>
><lst name="facet_counts">
> <lst name="facet_queries"/>
> <lst name="facet_fields">
>  <lst name="en_atmosphere">
>	<docs facet="Snug and pleasant">
>		<doc>...
>		<doc>...
>	</docs>
>	<docs facet="Authentic">
>		<doc>...
>		<doc>...
>	</docs>
>	...
>  </lst>
> </lst>
>
>Of course it would be possible to send a couple of queries for each facet to 
>get the corresponding docs or I can parse the response xml, but it would be 
>more efficient if SOLR can return the result as above.
>
>Thanks!
>
>-- 
>Jeffrey Gelens          Buyways B.V.          Tel. 050 853 6600
>Webengineer             Friesestraatweg 215c  Fax. 050 853 6601
>http://www.buyways.nl   9743 AD Groningen     KvK  01074105

-- 

===============================================================
Fergus McMenemie               Email:fergus@twig.me.uk
Techmore Ltd                   Phone:(UK) 07721 376021

Unix/Mac/Intranets             Analyst Programmer
===============================================================