I am using Solr 4.10 and our requirement is to have multiple facets. Each of the facet should filter should impact only the selected facet, but not other facets.
For example, lets say there are two facets BRAND and TYPE. When the user select brand as Nikon, then it should impact TYPE facet, but NOT the BRAND facet. Similar behavior for TYPE.
I tried implementing with tag and ex function and the query comes to something like this below,
/select?q=query&wt=json&start=0&rows=10&facet=true&fq={!tag=brand}brand:(Canon,Nikon)&fq={!tag=type}type:(TV)&facet.mincount=1&facet.field={!ex=brand}brand&facet.field={!ex=type}type&fl=id,brand,type
This works fine most of the cases, but when there are zero results, somehow Solr returns facets for one of the facet. For the above query, I get some value in type, even though there are no documents in the response.
Below is the response we get,
{
"response": {
"numFound": 0,
"start": 0,
"docs": []
},
"facet_counts": {
"facet_queries": {},
"facet_fields": {
"type": [
"TV",
4
],
"brand": []
},
"facet_dates": {},
"facet_ranges": {},
"facet_intervals": {}
}
}