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.

Comments

damien tournoud’s picture

Status: Active » Needs review
StatusFileSize
new1.48 KB

Port of the Apachesolr patch.

drunken monkey’s picture

Ah, 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.

derekwebb1’s picture

subscribing - 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.

valderama’s picture

I 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

danielnolde’s picture

Damien, 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?

drunken monkey’s picture

In 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?

markwittens’s picture

I 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?

markwittens’s picture

Never mind the question about the styling, just found the class facetapi-zero-results for these items. Don't know how I missed this yesterday...

drunken monkey’s picture

Status: Needs review » Fixed

Committed.
Thanks for testing!

Status: Fixed » Closed (fixed)

Automatically closed -- issue fixed for 2 weeks with no activity.

henrijs.seso’s picture

phpsubbarao’s picture

Hello,

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.