Computed Fields

Sometimes, recording information in a Sitecore template field isn’t practical, time-consuming, or error prone. If you need to store complementary information in your Coveo index items and this information can be determined using the same recipe from one item to the next, consider using a computed field instead.

Sitecore gives you the ability to create computed fields programmatically at indexing time using custom C# code and field configurations. Coveo for Sitecore simplifies the process of adding computed fields to your Coveo indexes by doing part of this work.

Note

In the Fields page of the Command Center, the Computed tab displays all computed fields you add or create, along with Sitecore’s own computed fields.

Image showing sample content of Computed fields in the Command Center

Coveo for Sitecore supports two main computed field implementation scenarios:

Using Coveo for Sitecore Out-Of-The-Box Computed Fields

Coveo for Sitecore includes out-of-the-box implementations that let you add computed fields for common use cases without any coding on your part. Coveo for Sitecore also provides commented out field indexing configurations for these computed fields in the Coveo.SearchProvider.Custom.config file, in the <fields hint="raw:AddComputedIndexField"> section. You only need to provide a few attribute values and enable the configuration to have your computed fields added on indexing.

Note

This configuration lets you create and index the computed field. If you want to apply special settings to that field (e.g., to use it as a facet or to sort results in a search interface), you also need to add a configuration in the fieldNames section of the configuration file.

  • Use Out-of-the-Box Computed Fields

    This article explains how to use the three Coveo for Sitecore computed field implementations (i.e., ImageUrlComputedField, ImageAltComputedField, and ReferencedFieldComputedField).

  • Create a Computed Field for a Referenced Item

    This article provides an example showing how to use the out-of-the-box ReferencedFieldComputedField computed field. ReferencedFieldComputedField is used to populate a departureairportcity field in Flight items by retrieving the content of a City field from a referenced Airport item.

Implementing a Computed Field of Your Own

In this scenario, you will need to code the logic of your computed field. Coveo for Sitecore provides a computed field configuration element structure. Minimal configuration is required to have your computed field added on indexing.

What's next for me?