Specify Which Fields to Index

The Sitecore Search Provider framework offers various parameters to alter item indexing.

One of them is fields inclusion and exclusion. This only affects the internal SitecoreItemCrawler module and not the Coveo Search Provider directly, so it can be used on any Sitecore Search Provider index.

Including or Excluding Fields from the Indexing

Coveo for Sitecore only indexes a small number of fields, the ones it needs to function properly. For more information on the entire field selection process, see About the coveoIndexingGetFields Pipeline.

There are several ways to include additional fields to the indexing process.

Updating the Configuration Files Directly

You can create a configuration patch for the list:AddIncludedField / list:AddExcludedField or list:IncludeField / list:ExcludeField for Sitecore versions prior to 8.1.

Here is an example of a field inclusion and exclusion configuration:

Sitecore 7 and 8.0

Add the following <include> and <exclude> elements as immediate children of the defaultIndexConfiguration element.

<include hint="list:IncludeField">
<exclude hint="list:ExcludeField">

Sitecore 8.1+

Add the following <include> and <exclude> elements as immediate children of the defaultIndexConfiguration/documentOptions element.

<include hint="list:AddIncludedField">
<exclude hint="list:AddExcludedField">

When including or excluding many fields, remember to use different element names for each field. Otherwise, only the last child of the <include>/<exclude> element of a given name will actually be included/excluded.

Using the Coveo Command Center

The Coveo Command Center is the easiest way to browse through all the Sitecore fields and choose which ones to index (see About the Indexing Manager - Fields).

All the selected fields are added to the list:AddIncludedField in Sitecore versions 8.1 and newer, or the list:IncludeField for versions prior to Sitecore 8.1.

Using Both Configuration Files and the Command Center

You can include fields using both configuration files and the Command Center. However, you might be surprised by certain system behaviors if you don’t properly understand:

  • what happens when you add or remove fields using the Command Center
  • how Coveo for Sitecore ultimately determines the list of fields to index

The following diagram shows an example of a field inclusion patch file configuration. Including or excluding a field through the Command Center simply adds/removes a field element in the <include> element of the last Coveo for Sitecore configuration patch file in the file patching order (Coveo.SearchProvider.Fields.Custom.config). Field elements added within the <include> element of Coveo.SearchProvider.Fields.Custom.config follow a naming convention that make them unique, such that they’re always added to the field elements you might have added in Coveo.SearchProvider.Custom.config.

At run time, the IncludeFieldsFromConfigOnlyProcessor processor retrieves the field elements in the <include hint="list:AddIncludedField" > element of the compiled configuration (see Default Processing Sequence Diagram). These are the fields Coveo for Sitecore ultimately indexes.

Hence, with the sample configuration above, if you try using the Command Center to remove one of the two fields that you included through the Coveo.SearchProvider.Custom.config file, you won’t notice, after the Save & Restart, that Coveo for Sitecore has not removed the field. The only way for you to exclude those two fields now is to remove them from the Coveo.SearchProvider.Custom.config file.

Using a Coveo for Sitecore Pipeline

You can include and exclude fields using the coveoPostItemProcessingPipeline (see About the coveoPostItemProcessingPipeline Pipeline).

Using the Coveo for Sitecore Indexing API

The Coveo for Sitecore Indexing API offers several methods to update the fields list (see Coveo for Sitecore Indexes Service API).

What's Next for Me?