Hi,

is it possible to always show all terms as facets even when there are no results, but eg. with a zero between brackets as the result count.
This would also affect the filtering: clicking a facet link would always show all facets, but the ones with zero results should obviously be unclickable.

(Converting them into checkboxes would be a nice extra with the facets without results being disables checkboxes)

Thx in advance,

Eddib

Comments

drunken monkey’s picture

With the move to Facet API (#1182614: Integrate with Facet API) the display part will become much easier for you to do.
However, this isn't really planned for the Search API directly, as this would require a significant API change (or addition), which I think would benefit only few users.
Also, and probably more importantly, I don't think such facets are even supported by Solr.
Anyways, since you would want all facets to be displayed, you can simply code this for yourselves. Just save the facets for a blank search somewhere and always complete the displayed facets with the missing ones.

-otto-’s picture

Thanks for your fast reply.

The blank search is a good idea. I'll give that a go.
I think I could also use this to show the facets on a non-search page, clicking a facet would then redirect to the search (why? well, some clients want strange things, like showing the facets on a totally unrelated page).

I'll take a look at it this weekend when I have some time to dig into the API.

and btw, great module. thx for that :)

drunken monkey’s picture

I think I could also use this to show the facets on a non-search page, clicking a facet would then redirect to the search (why? well, some clients want strange things, like showing the facets on a totally unrelated page).

I don't think that's strange at all, this could be very useful for landing pages and the like – in fact, there is already a Views display plugin ("Facet block") that you can use to do exactly that. However, as you need the other functionality, too, anyways, you are probably better off with a custom solution.

derekwebb1’s picture

I am researching this same need for a client project. subscribing

henrijs.seso’s picture

I don't get this. Removal of facets with results happens in Search API protected function addFacetFilter. Just commenting out line $query_filter->condition($field, $filter); from file query_type_term.inc does the trick.

Is there a way to tell Search API not to filter facets from code in other module? I am developing one for clients - it places all facets in single form with one submit button and client wants to see more "no results" pages ;)

msizec’s picture

Issue summary: View changes

I would like to do the same here : display all facets, even if there is no results in the view.

Is there a way now, 4 yours later, to do this easily ?

If not, could you give me more clues ?

Would really appreciate ... thx !

drunken monkey’s picture

Status: Active » Fixed

You can set the minimum count to 0 for the facet, that should work.

msizec’s picture

drunken monkey, it works as intended : showing facets when there are results. But the issue/question here is to show them when there are no results ...

https://www.drupal.org/node/2512864

drunken monkey’s picture

drunken monkey, it works as intended : showing facets when there are results. But the issue/question here is to show them when there are no results ...

Ah, then you are probably using the "Database" backend for your server and would need #2219897: Show facets on "no results found" search.

Status: Fixed » Closed (fixed)

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