6

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!

Paul Kerrison
  • 71
  • 1
  • 1
  • 8
  • It has been a long time since you had asked this query. Did you find any good way of supporting this, compared to the answers below? I am facing the same issue, so thought if you can share your findings. – Ethan Mar 03 '15 at 12:56

2 Answers2

1

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.

Paige Cook
  • 22,415
  • 3
  • 57
  • 68
  • Thanks Paige - I'd read through that link earlier. My problem is that even when you set facet.mincount - you still have to specify one or more facet fields: Eg select?q=ipod&rows=0&facet=true&facet.limit=-1&facet.field=cat&facet.mincount=1&facet.field=inStock (where I would be specifying the fields "cat" and "inStock") I'd like to know how I can do a query, but *not* specify the fields. I would like all the fields with positive counts to be returned. – Paul Kerrison Sep 29 '11 at 00:43
  • 2
    You cannot get facets without specifying fields to facet on. Sorry that is just how the application works. You could turn on faceting for all of the fields that you *might* be interested in and then do some pre-processing of the results to only display the ones that are relevant based on the returned results... – Paige Cook Sep 29 '11 at 00:48
  • 1
    ah right - thanks again. That's a pity - once I've done a search I can't be sure which facet fields will be applicable to the search results returned. Across my entire product range there are many diverse products and as a result many facet fields...Looks like I will have to manage a facet field hierarchy separately so that I know which fields to facet on. It looks like they were considering a wildcard syntax - but then thought it was abad idea - https://issues.apache.org/jira/browse/SOLR-247 – Paul Kerrison Sep 29 '11 at 08:59
  • 1
    This is why amazon.com makes you select a category before you can facet. 1) Go search for "puppies". On the left side you get categories to choose from. 2) Once you pick a category that determines what facets are appropriate for that type of product. If you pick books, you get author facet. If you pick toys, you get age range. – Evan Oct 24 '12 at 17:03
1

Im having the same problem.

What I eventually did was to query Solr for the top 50 hits for a given query and then collect the names of the properties set on those products. I then do another query with the facet fields set to the product properties I found first time around.