Gravatar for

Question by mschultz, Sep 29, 2014 7:45 PM

Dependent facets in coveo

Hi Coveo,

I have a requirement on an upcoming "Coveo for Sitecore" based project to implement dependent facets. The initial facet we want to display will slice the search results into groups that have different sets of facets. We'd like to let the user first choose the initial facet and then show the other facets after making a selection from the first facet.

Does Coveo have support for this concept (I think the answer is not explicitly) and is there a preferred way that you would implement this requirement custom or otherwise?



2 Replies
Gravatar for

Answer by Vincent Séguin, Sep 30, 2014 7:32 AM

Hi Matt!

I've been doing something similar on my side for a current project, and it looks like that :

        Coveo.$('#search').on('state:change:f:@Html.Coveo().ToCoveoFieldName("recipeCourses")', function (e, data) {
            if (data.value.length) {
            } else {

So according to the state of the 'recipeCourses' facet, it shows or hides another facet. Is it something like this you're looking for?

(BTW, credit to AlexP for this)

Gravatar for

Answer by Martin Laporte, Sep 30, 2014 3:57 AM

We do not (yet) have anything that does this out-of-the-box, but we might very well add it since it's an often requested feature.

Still, it's not very hard to get this result with some custom JS code. What you want to do is monitor the state using the provided events to enable/disable your child facets depending on the selection in the parent facet. This page describes how to read and monitor the state:

I have to jump on a call so I can't provide some sample code just now, but feel free to comment if you need more information.

Ask a question