Specify which templates to index
Specify which templates to index
The Sitecore Search Provider framework offers several mechanisms to customize item indexing. One of these is template inclusion and exclusion.
By default, all Sitecore items under the specified crawling roots are indexed. Template inclusions and exclusions allow you to control which items are indexed based on their originating Sitecore template.
This article explains how to configure template inclusions or exclusions specifically for Coveo indexes.
Including or excluding templates from the Coveo indexes
You can configure template inclusions or exclusions in the <SITECORE_INSTANCE_ROOT>\App_Config\Include\Coveo\Coveo.SearchProvider.Custom.config
file as follows:
-
Add an
<include hint="list:AddIncludedTemplate">
or<exclude hint="list:AddExcludedTemplate">
element as a child of theconfiguration/sitecore/coveo/defaultIndexConfiguration/documentOptions
element.Sitecore prioritizes inclusions over exclusions. When you specify template inclusions, any items based on other templates will be excluded, effectively overriding any existing template exclusion configuration. Don’t define both inclusions and exclusions; only define one or the other.
-
Specify the Sitecore templates to be included or excluded as child elements, using their
Item ID
.When including or excluding multiple templates, assign a unique element name to each template. If you use the same name, only the last element with that name will be applied. Using descriptive template element names not only ensures correct indexing behavior but also helps in identifying which content is included or excluded.
Inclusion example
The following inclusion configuration ensures that all items based on the {BEAE618D-3D5B-483A-A9B3-2A5938DEB9A3}
template or the {906B3C98-629B-41D6-890D-EF13B3C1E47D}
template are indexed.
<include hint="list:AddIncludedTemplate">
<librariesTemplate>{BEAE618D-3D5B-483A-A9B3-2A5938DEB9A3}</librariesTemplate>
<parksTemplate>{906B3C98-629B-41D6-890D-EF13B3C1E47D}</parksTemplate>
</include>
Exclusion example
The following exclusion configuration ensures that all items based on the {930B0A7B-BACA-4D1E-B108-205CFDA1E778}
template or the {5D1786F8-5165-413A-A299-A39ECDD4B0D3}
template are excluded from indexing[1].
<exclude hint="list:AddExcludedTemplate">
<roadwaysTemplate>{930B0A7B-BACA-4D1E-B108-205CFDA1E778}</roadwaysTemplate>
<parkingsTemplate>{5D1786F8-5165-413A-A299-A39ECDD4B0D3}</parkingsTemplate>
</exclude>
Rebuilding the index
After modifying your template inclusion or exclusion settings, you must rebuild the index for the changes to be reflected in your items.