Gravatar for

Question by Simon, May 5, 2014 4:45 PM

Filtering out items from certain templates using the Javascript Search UI

I am using inbound filters to exclude items out of my Coveo for Sitecore index but now I would like to know how to apply this type of filter directly on the search interface using the JS UI.

My guess would be to use the filterField defined here:

Still, I am not a 100% sure on how to use it to filter out items from a certain template. Anyone has a code snippet for this?


3 Replies
Gravatar for

Answer by Gregory Laporte, May 5, 2014 4:47 PM

You can do this. Filter field is not what you are looking for. In your case, you want to use hiddenExpression.

<div class="CoveoSearchInterface" data-hidden-expression="NOT @myfield==something"></div>

Gravatar for

Answer by Nicolas, May 6, 2014 10:21 AM

If you want to configure this through the Sitecore interface (which makes it easier to deploy on content delivery servers) I would suggest to use the Filter Expression defined on the Coveo Search component. You can use the "where the item template is specific template" rule to make it easier to pick a specific template from Sitecore tree.

Refer to the section Adding a Filter Expression from this page:

The other option would be to add an hiddenExpression directly in the markup of the ascx search component.

Gravatar for

Answer by mohamed krimi, Nov 4, 2014 12:21 PM

Hi Nick, Rule Editor is only available for the Entreprise Edition. If we would like to do the same thing with Hidden Expression. Is that the right way to do it ? (This is not working for me)

<div id="search" class="CoveoSearchInterface" data-enable-history="@Model.EnableHistory"
Gravatar for

Comment by Vincent Séguin, Nov 4, 2014 12:54 PM

Hi Mohamed,

This is not the right way to do it. Follow this page :

Gravatar for

Comment by mohamed krimi, Nov 4, 2014 1:12 PM

Thanks Vincent for the quick replay.

Ask a question