/ Coveo

Enhancing Coveo Search with Computed Fields (Part-1)

Coveo provides powerful indexing and search with Sitecore.

What Are Coveo Computed Fields?

Computed fields in Coveo allow you to perform calculations on indexed data at query time or during indexing. These fields are particularly useful when you need to pull values dynamically

  • Full name (Combining First name and last name with degree)
  • Location lat long computation with address or zip code
    Rather than computing these values dynamically in your application, you can have Coveo handle them at the indexing level, reducing processing time and improving query performance.

Out-of-the-Box Computed Fields

Coveo for sitecore has computed fields out of the box that could be utilized with just the configuration changes. we dont have to write code for some basic use case.
Coveo for Sitecore provides field indexing configurations for these computed fields in the Coveo.SearchProvider.Custom.config file that is commented out.

ReferencedFieldComputedField

This field type is mainly used for retrieving a specific field from an item.

The following class should be used in the field defintion Coveo.SearchProvider.ComputedFields.ReferencedFieldComputedField, Coveo.SearchProviderBase

Example:
Media Item would reference a file that contains the mime type

Enhancing-Coveo-Search-with-Computed-Fields_1-1

  • fieldName: The resulting name of the field in the Coveo index.
  • sourceField: The name of the field in your indexable item that have a value to be replaced.
  • referencedFieldName: The name of the field on the referenced item that contains the value to be used.

ImageUrlComputedField

Image url computed field retrieves the URL of an image that is referenced in an image field type.

The following class should be used in the field defintion
Coveo.SearchProvider.ComputedFields.ImageUrlComputedField, Coveo.SearchProviderBase

ImageAltComputedField

Image alt computed field retrieves the alt text of an image that is referenced in an image field type.

The following class should be used in the field defintion
Coveo.SearchProvider.ComputedFields.ImageAltComputedField, Coveo.SearchProviderBase

Validate

The created field can be validated after a config sync from Sitecore.
Navigate to the Coveo platform on cloud and naviagate to the fields in the content section and ensure the field is available.

Enhancing-Coveo-Search-with-Computed-Fields_2

Now index an item, valid to this scenario. Navigate to the content browser do a search for that item and ensure the field values are populated as expected.

Enhancing-Coveo-Search-with-Computed-Fields_3

We will explore the Custom Computed fields in the next blog post.