Gravatar for diego.moretto@xcentium.com

Question by Diego, Sep 6, 2016 1:33 PM

Facet Component keep filters when no search results

hey guys

if I open https://search.coveo.com/#sort=relevancy&f:languageFacet=[English] and search for any dummy words that will reflect as no results it will by default hide the facets on the left hand side. I have a similar scenario here but in my case I want to keep the facets with the original filters to enable the user to click on those and quickly showing results as per those filters. How can I get something like that done? I haven't seen any properties on the facet components that seemed to do what I'm trying to do.

thanks

1 Reply
Gravatar for mlaporte@coveo.com

Answer by Martin Laporte, Sep 7, 2016 4:26 AM

The part that clears the facets on no-results is in fact particular to search.coveo.com. On a vanilla search page if you select a facet value and then search for keywords that match nothing, the facet with a selection will remain visible to allow the user to manually clear the filter. But the other facets will become hidden, since they are used to drill down in the result set matching the keywords you entered. If those keywords match nothing, well, there is nothing to drill down into..

Gravatar for diego.moretto@xcentium.com

Comment by Diego, Sep 7, 2016 9:02 AM

Thank you. But what if I don't select any facets and just make a query that matches nothing, how can I keep all facets showing? From what you said Coveo will hide all the facets because there is not matching results right? What if I want to keep showing the facets and when a facet is selected it will reset the query?

Gravatar for mlaporte@coveo.com

Comment by Martin Laporte, Sep 12, 2016 3:27 AM

That behavior is not supported OOTB, since facets always show a representation of the results of the current query (with some twists). What you could do is use the noResults event (https://coveo.github.io/search-ui/classes/queryevents.html#noresults) to display a message, clear out the query keywords, and then run another query. That'll give you the facets for the whole available content.

Gravatar for diego.moretto@xcentium.com

Comment by Diego, Sep 12, 2016 9:55 AM

ok thank you

Ask a question