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

Tip
Leading practice

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

In the <SITECORE_INSTANCE_ROOT>\App_Config\Include\Coveo\Coveo.SearchProvider.Custom.config patch file, 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.

Important

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).