(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.
| Comment | File | Size | Author |
|---|---|---|---|
| #3 | 1957890-3--facet_fixes.patch | 5.39 KB | drunken monkey |
| #2 | 1957890-2--facet_fixes.patch | 5.49 KB | drunken monkey |
| #1 | search_api_solr-hide-facets-that-dont-narrow-results-1957890.patch | 1.22 KB | jwilson3 |
Comments
Comment #1
jwilson3Comment #2
drunken monkeyAs 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!Comment #3
drunken monkeyRe-roll because of #1846254: Remove the SolrPhpClient dependency.
Comment #4
drunken monkeyCommitted. Thanks again for your patch!