See #1305052: Negative facets not displayed when the mincount is 0
Original post by @cpliakas:
The "negative facet" pattern allows for facets with no results to be displayed. See this screenshot for more details on what this pattern looks like. This is achieved by setting the "Minimum facet count" setting to 0 in the Facet API interface. Even when setting this to 0, the facets are stripped out by Apache Solr Search Integration and never displayed due to logic in the ApacheSolrFacetapiTerm::build() method that always strips facets with 0 results.
| Comment | File | Size | Author |
|---|---|---|---|
| #2 | 1306008--allow-facets-with-no-results-2.patch | 2.09 KB | drunken monkey |
| #1 | 1306008-negative-facets.patch | 1.48 KB | damien tournoud |
Comments
Comment #1
damien tournoud commentedPort of the Apachesolr patch.
Comment #2
drunken monkeyAh, yes, that is an unnecessary restriction. Didn't know Solr could do this natively, though. But it should of course be supported in any case.
I just think that we can then remove the condition altogether – it's now just
$value['count'] >= $settings->settings['facet_mincount']essentially, and that should already always hold due to the contract for facets returned by the server.Please see/test/review the attached patch.
Comment #3
derekwebb1 commentedsubscribing - with search_api 7.x-1.0 and facetapi at 7.x-1.0-rc1, the mincount is still not working as desired when the count is set to 0 on my setup.
Comment #4
valderama commentedI wonder if I get it right?
The patch above respects the facet_mincount setting for the apache solr backend. When using the search_api_db Backend there is still no way to keep the facets with no results visible?
Thanks,
Walter
Comment #5
danielnolde commentedDamien, Thomas, all others:
i have the same questions as valderama: The patch bei Damien only solves the problem for Apache Solr backend, noch the search_api_db backend, right?
Could a negative facet pattern be implemented on top of db search at all?
What about an "OR"-ing of multiple active facet items?
Comment #6
drunken monkeyIn principle this would be possible to implement, yes. Maybe we can add a feature/option for that?
However, this is a different issuem, I guess. This one is just about fixing the mincount.
So, does the last patch work?
Comment #7
markwittens commentedI can confirm the last patch applies smoothly and works as expected. I would like to be able to style the negative items in a different way but there are no extra classes for this in the filter facets, not sure if this is the right place to ask about this?
Comment #8
markwittens commentedNever mind the question about the styling, just found the class facetapi-zero-results for these items. Don't know how I missed this yesterday...
Comment #9
drunken monkeyCommitted.
Thanks for testing!
Comment #11
henrijs.seso commentedFor search api db backend, see issue #1232632: Show all terms as facets, even when there are no results..
Comment #12
phpsubbarao commentedHello,
I am unable to display Min count 0 values records, even we added your patch also.
Current Version: 7.x-1.5
Thanks in advance.