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.

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

Updating the Configuration Files Directly

Using the Command Center is now recommended over updating configuration files directly.

You can edit the Coveo.SearchProvider.Custom.config patch 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 fields 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:IncludeField"> or <exclude hint="list:ExcludeField"> elements as immediate children of the configuration/sitecore/coveo/defaultIndexConfiguration/documentOptions element. Then, specify the Sitecore fields to be included/excluded as child elements using their Item ID.

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. Descriptive field element names can serve this purpose and help you identify the content you’re including or excluding from the index.

EXAMPLE
<include hint="list:IncludeField">
  <field1>{BDB6FA46-2F76-4BDE-8138-52B56C2FC47E}</field1>
  <field2>{6183C9C8-91EE-4F40-BDCE-FCF61587C0B9}</field2>
</include>
EXAMPLE
<exclude hint="list:ExcludeField">
  <field3>{2D748E03-467B-4701-BCA0-0458E796649E}</field3>
  <field4>{A91641B8-D67E-4F78-B0BF-8FFE7A62A99D}</field4>
</exclude>

Sitecore 8.1 and Later Versions

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

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. Descriptive field element names can serve this purpose and help you identify the content you’re including or excluding from the index.

EXAMPLE
<include hint="list:AddIncludedField">
  <field5>{BEAE618D-3D5B-483A-A9B3-2A5938DEB9A3}</field5>
  <field6>{906B3C98-629B-41D6-890D-EF13B3C1E47D}</field6>
</include>
EXAMPLE
<exclude hint="list:AddExcludedField">
  <field7>{930B0A7B-BACA-4D1E-B108-205CFDA1E778}</field7>
  <field8>{5D1786F8-5165-413A-A299-A39ECDD4B0D3}</field8>
</exclude>

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.

IncludeFieldsFilePatchOrder

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?