Specify Which Templates to Index

The Sitecore Search Provider framework offers various mechanisms to alter item indexing. One of them is template inclusion and exclusion.

By default, all Sitecore items under specified crawling roots are indexed. Template inclusion/exclusion lets you specify the items under these crawling roots that should be indexed, based on the Sitecore template they originate from.

This article focuses on configuring template inclusion/exclusion for Coveo indexes.

Including or Excluding Templates from the Coveo Indexes

To apply the configuration only to Coveo for Sitecore indexes, you must edit the Coveo.SearchProvider.Custom.config file.

The Coveo.SearchProvider.Custom.config file is located in the <SITECORE_INSTANCE_ROOT>\Website\App_Config\Include\Coveo\ folder in Sitecore 7 and 8 instances and in the <SITECORE_INSTANCE_ROOT>\App_Config\Include\Coveo\ folder in Sitecore 9 and 10 instances.

The way to specify templates to include or exclude depends whether you’re using a Sitecore version prior to 8.1 or version 8.1 or later.

The hint attribute value of the <include> and <exclude> configuration elements changed between Sitecore 8.0 and 8.1.

Sitecore Versions Prior to 8.1

Use <include hint="list:IncludeTemplate"> or <exclude hint="list:ExcludeTemplate"> elements as immediate children of the configuration/sitecore/coveo/defaultIndexConfiguration/documentOptions element. Then, specify the Sitecore templates to be included/excluded as child elements using their Item ID.

When including or excluding multiple templates, remember to use unique element names for each template. Otherwise, only the last child of the <include>/<exclude> element of a given name will actually be included/excluded. Descriptive template element names can serve this purpose and help you identify the content you’re including or excluding from the index.

EXAMPLE
<include hint="list:IncludeTemplate">
  <familyTemplate>{BDB6FA46-2F76-4BDE-8138-52B56C2FC47E}</familyTemplate>
  <healthTemplate>{6183C9C8-91EE-4F40-BDCE-FCF61587C0B9}</healthTemplate>
</include>
EXAMPLE
<exclude hint="list:ExcludeTemplate">
  <laborTemplate>{2D748E03-467B-4701-BCA0-0458E796649E}</laborTemplate>
  <educationTemplate>{A91641B8-D67E-4F78-B0BF-8FFE7A62A99D}</educationTemplate>
</exclude>

Excluding items from the indexing means that those items aren’t crawled anymore. If you already had items based on these templates in your index, they won’t be automatically removed from the index. You must run a rebuild to delete them.

Sitecore 8.1 and Later Versions

Use <include hint="list:AddIncludedTemplate"> or <exclude hint="list:AddExcludedTemplate"> elements as immediate children of the configuration/sitecore/coveo/defaultIndexConfiguration/documentOptions element. Then, specify the Sitecore templates to be included/excluded as child elements using their Item ID.

When including or excluding multiple templates, remember to use unique element names for each template. Otherwise, only the last child of the <include>/<exclude> element of a given name will actually be included/excluded. Descriptive template element names can serve this purpose and help you identify the content you’re including or excluding from the index.

EXAMPLE
<include hint="list:AddIncludedTemplate">
  <librariesTemplate>{BEAE618D-3D5B-483A-A9B3-2A5938DEB9A3}</librariesTemplate>
  <parksTemplate>{906B3C98-629B-41D6-890D-EF13B3C1E47D}</parksTemplate>
</include>
EXAMPLE
<exclude hint="list:AddExcludedTemplate">
  <roadwaysTemplate>{930B0A7B-BACA-4D1E-B108-205CFDA1E778}</roadwaysTemplate>
  <parkingsTemplate>{5D1786F8-5165-413A-A299-A39ECDD4B0D3}</parkingsTemplate>
</exclude>

Excluding items from the indexing means that those items aren’t crawled anymore. If you already had items based on these templates in your index, they won’t be automatically removed from the index. You must run a rebuild to delete them.

What's Next for Me?