THIS IS ARCHIVED DOCUMENTATION

Creating Computed Fields

Computed fields allow you to add new fields in your search indexes. Ultimately, this means that you will end up with additional fields in your Coveo index, in addition to those of Sitecore.

Guidelines

  • A computed field is processed for every Sitecore item that gets re-indexed.
  • A computed field is normally used to add complementary information to indexed Sitecore items.
  • A computed field must be implemented using custom C# code. Since it’s executed in the context of Sitecore, you can take advantage of using the Sitecore API.
  • The more complex a computed field logic is, the slower to process it will be.

Implementing a Computed Field

There are essentially four different steps required when you implement a computed field:

  1. Implement the computed field using custom C# code (you must implement the Sitecore.ContentSearch.ComputedFields.IComputedIndexField interface).
  2. Add the computed field in the Coveo.SearchProvider.Custom.config file. It must be added under fieldNames hint=”raw:AddFieldByFieldName”.
  3. Rebuild your search indexes, or at least re-index the Sitecore items that need your new field.
  4. Use the new field in whatever way is needed. For example, you may want to display it in a search interface.

Computed index field code is executed at indexing time. If the code isn’t optimized, it can slow down the whole indexing process.

  • Avoid running HTTP requests
  • Avoid querying a search index

Examples

Here are complete tutorials showing you how to implement and use a computed field: