Query Filter

Coveo for Sitecore Specific Rendering Implements the CoveoForSitecoreFilterExpression component which adds a filter expression (often created through the Sitecore Rules Editor) to the advanced query expression (aq).

Usage Notes

  • The Sitecore Rules Editor is only available with the Enterprise Edition. The Sitecore Rules Editor is required to set Filter expression rules in the data source. Therefore, when not using the Enterprise Edition, only the Exclude bucket folders in results and Exclude media folders in results options are shown in the data source.

  • The Query Filter rendering is added automatically with the Coveo Search Interface rendering and Coveo Tab renderings.

Insertion Location

The Query Filter rendering is an Allowed Control in the following placeholder(s): UI Header, Recommendations Components, Searchbox Components

Example insertion sequence for the Query Filter rendering.

The Coveo for Sitecore SXA Query Filter rendering is meant to be inserted in specific placeholders (i.e., UI Header, Recommendations Components, Searchbox Components).

Example insertion sequence for the Query Filter rendering.

Data Source Options

Option name Description
Enterprise only
Filter expression rules
List of filter expression rules to apply on queries. When querying on a Coveo Tab where a filter expression rule has been set, this rule is applied on top of rules set on the Coveo Search Interface.
Exclude bucket folders in results Specifies whether to exclude bucket folder items from results. When selected, either in the Coveo Search Interface or in the active Coveo Tab data source, this option adds NOT(_template == ADB6CA4F03EF4F47B9AC9CE2BA53FF97) to the advanced query expression (aq).
Exclude media folders in results1 Specifies whether to exclude media folder items from results. When selected, either in the Coveo Search Interface or in the active Coveo Tab data source, this option adds NOT(_template == FE5DD82648C6436DB87A7C4210C7413B) to the advanced query expression (aq).

1: By default, the MediaLibraryCrawler only indexes items under /sitecore/media library/Files in the Sitecore content tree.

Sample Generated HTML and Corresponding Query Expressions

In the example below, Query Filter data sources are configured both on the Coveo Search Interface and on a specific Coveo Tab.

On the Coveo Search Interface, the data source options are set as follows:

  • Filter expression rule: where the item has layout
  • Exclude bucket folders in results: enabled
  • Exclude media folders in results: enabled

Coveo Search Interface HTML:

<div class="CoveoForSitecoreFilterExpression" 
data-sc-filter-scope-node="{"advanced" : {"type" : "and" , "left" : {"type" : "field" ,
"fieldName" : "HasLayout" , "operator" : {"name" : "==" , "value" : 1},
"fieldValueType" : {"name" : "boolean" , "value" : 0},"fieldValues" : [true]},
"right" : {"type" : "not" , "operand" : {"type" : "field" , "fieldName" : "_template" ,
"operator" : {"name" : "==" , "value" : 1},"fieldValueType" : {"name" : "string" ,
"value" : 3},"fieldValues" : ["ADB6CA4F03EF4F47B9AC9CE2BA53FF97" , 
"FE5DD82648C6436DB87A7C4210C7413B"]}}}}">
</div>

On a Coveo Tab, the data source options are set as follows:

  • Filter expression rule: where the item is the Blog articles item (i.e., Item ID = 713B102E34824750AC6F46E08ECFC163) or one of its subitems
  • Exclude bucket folders in results: disabled
  • Exclude media folders in results: disabled

Coveo Tab HTML:

<div class="CoveoForSitecoreFilterExpression" data-sc-scope-to-tab="coveod9c70725" 
data-sc-filter-scope-node="{"advanced" : {"type" : "field" , "fieldName" : "_path" ,
"operator" : {"name" : "==" , "value" : 1},"fieldValueType" : {"name" : "string" ,
"value" : 3},"fieldValues" : ["713B102E34824750AC6F46E08ECFC163"]}}">
</div>

Search API call aq when that Coveo Tab is the active:

Query Filter AQ

What's Next for Me?