Computed fields
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 Platform source 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. |
Coveo for Sitecore supports two main computed field implementation scenarios:
-
Creating and adding your own computed fields to your Coveo indexes.
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 (for example, to use it as a facet or to sort results), you also need to add a configuration in the |
Related articles
-
Use out-of-the-box computed fields
This article explains how to use the three Coveo for Sitecore computed field implementations (that is,
ImageUrlComputedField
,ImageAltComputedField
, andReferencedFieldComputedField
). -
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 adepartureairportcity
field in Flight items by retrieving the content of aCity
field from a referenced Airport item.
Implementing a computed field of your own
In this scenario, you’ll 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.
When running computed field code, check your logs for computed field errors indicating items aren’t being indexed. Implement proper exception handling to avoid these issues. For example, you might want to stop the process or set a fallback value for a computed field when suitable. |
Related articles
-
Implement and configure a computed field in your index
This article gives you complete step-by-step instructions on how to add your own computed fields in Coveo index items, from setting up your C# project to using your computed fields in search interfaces.
-
This article is an example showing how to create a computed archive date based on the item creation date.
-
This article is a continuation of the Create a computed date field example. The implementation is modified to retrieve and use a value from the configuration to compute the item archive date.