0

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": {}
}

}

Abhijit Bashetti
  • 8,518
  • 7
  • 35
  • 47
  • maybe the facet.mincount is set to a number larger than zero try facet.mincount=0 and check again – user3687679 Jun 01 '15 at 09:25
  • I tried facet.mincount=0, it does not fixes the issue. The reason being there are 4 items returned in TYPE field, so the facet is still displayed. Is there a known bug in Solr with this kind of facet/filter. Any help would be appreciated. Thanks. – user2121940 Jun 02 '15 at 02:24

0 Answers0