How do I retrieve all applicable facet fields for a Solr search

Paul Kerrison picture Paul Kerrison · Sep 28, 2011 · Viewed 12.3k times · Source

I'm trying to use Solr for faceted-seaarch on a website.

When a user fires off a search query, I query Solr and retrieve the search results which can then be displayed.

My question is - how do I find out which facet fields and terms are applicable to the search results?

To be clear - different categories of products have different facet fields and I want to find a way to bring back the most relevant facet fields for the search results that have been returned. I don't want to have to specify the fields - I'd like Solr to identify the relevant ones for me.

Thanks in advance!

Answer

Paige Cook picture Paige Cook · Sep 28, 2011

I would recommend looking over all of the Simple Facet Parameters on the Solr Wiki, especially the examples at the bottom as they will show you all of the possible ways that you can configure the faceting results for your queries.

If I am understanding your question correctly... by default faceting will only bring back facets/counts based on the documents in the result set. However to make those more relevant to the search, you should set the facet.mincount to something other than the default value of 0. eg. &facet.mincount=1. But, again please refer to the documentation on how this works and can be applied to your scenario.