Converting Sitecore Field Names To Coveo

When working with Coveo, Sitecore field names need to be translated to Coveo field names.

A translation consists of substituting special characters and add machine-specific hashcode to the end of each field name. Here is a sample of the difference between two field name.

Sitecore Field Name Coveo Field Name
__created by @fz95xz95xcreatedz32xby66296

Explained:

Segment Explanation
@ Coveo fields start with @
f Sitecore fields are prefixed with f
z95x underscore
z32x space
66296 machine hash code

So how do we convert our field names?

The search pages in most implementations center on CoveoSearch.ascx which has access to the ToCoveoFieldName() helper through it's code-behind. Technically it's through the CoveoUserControl class inherited by the Coveo.UI.CoveoSearch user control, but I digress.

When working with Coveo outside of CoveoSearch.ascx, how do you access Coveo's field names?

They've provided a simple utility:


SitecoreUtilities.ToCoveoFieldName(p_SitecoreField string, p_UsePrefix bool = true);

It's a static method located in Coveo.UI.SitecoreUtilities. As your implementation gets more creative, it will definitely come in handy.

This post was written used Markdown for Sitecore.

Fish