12
votes

I'm a newbie to solr and tying my hands at solr. Can some one here please explain how to specify multiple facet fields for a given search.

I'm using the Solr Admin UI/ query ink and it allows me to specify only one field. I would however like to facet on multiple fields like region industry stock-exchange etc on my company search.

I have gone through the solr wiki and relevant doc links like the one below http://docs.lucidworks.com/display/solr/Query+Screen

but none of them seem to explain how to specify multiple fields. I want to build something like the usual Amazon/Walmart etc search ui that provides multiple facets and counts when trying to search for a product on my planned cmpany search page.

5
Got to this question googling for multiple nested facets, for anyone else who is looking for that (like total positive, negative and neutral comments by month) here are some links: yonik.com/solr-subfacetsHMR
Is the same possible through Solr panel(UI) ?Nikhil Sahu

5 Answers

17
votes

You can query multiple facet fields. Just write with the syntax:

.../select?q=&facet=true&facet.field=<field1>&facet.field=<field2>
2
votes

When you execute the search in the Solr Query UI, it will show the actual url that is being sent to Solr above the results pane. Click on that url and it will open a new window in your browser to that url. From there you can add additional parameters to the url to get facteing on multiple fields, by adding additional &facet.field=<your field> entries.

Please see the Solr Faceting Parameters reference for more details and other options.

0
votes

The Solr Admin UI allows you to specify multiple facets fields i.e. a csv of fields in the facet.field parameter. You need to check the facet checkbox and then you will get more options.

If you are querying Solr using a link then the link should look like - facet=true&facet.field=field1&facet.field=field2.

0
votes

You are looking for json.facet

It's available from solr 5(some advanced features are available from solr 6). Basically that means you can insert your facet search parameters via json to the url.

It looks like this(live example):

&facet=true&json.facet={"filed1":{"type":"terms","field":"filed1","limit":2000},"filed2":{"type":"terms","field":"filed2","limit":2000}}

There is also a shorter version:

&facet=true&json.facet={"field1":{"terms":"field1"},"field2":{"terms":"field2"}}

You can find more information here