(This is a follow up issue from #1934450: Fix reference to removed method getFacetField() for the other half of the original patch provided on #1846840-3: Fatal error: Call to undefined method SearchApiSolrService::getFacetField().)

There is a line of code in class SearchApiSolrService that hides facet groupings that have only one facet option in them, however when using Search API Multi-Index Facets it is often the case that a single facet link will still narrow down the result list.

In the case where there is one single facet link, instead of removing it wholesale, we should first test whether it would still narrow down the results list by comparing that facet's match count to the total results count.

Patch to follow in first comment.

Comments

jwilson3’s picture

Status: Active » Needs review
StatusFileSize
new1.22 KB
drunken monkey’s picture

Title: Only remove single facets when they don't narrow the results » Several bugs for facets
Category: feature » bug
StatusFileSize
new5.49 KB

As already said in the other issue, I support this request, and your patch also looks good. Thanks!
We actually already removed this check for normal facets, but (as always) I forgot to also do it for the queryMultiple() method. For normal facets, however, we completely removed the check and always return even single facets, which I think makes more sense. After all, if you don't want this, you can configure it yourself already (admittedly, you need the Facet API Bonus module, but still).

So, with this in mind, here's a revised patch. I incorporated some other changes in the original facet code, too, and copied everything down to the queryMultiple() method. Please test/review!

drunken monkey’s picture

StatusFileSize
new5.39 KB
drunken monkey’s picture

Status: Needs review » Fixed

Committed. Thanks again for your patch!

Status: Fixed » Closed (fixed)

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