Insights

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.

👋 Hey Sitecore Enthusiasts!

Sign up to our bi-weekly newsletter for a bite-sized curation of valuable insight from the Sitecore community.

What’s in it for you?

  • Stay up-to-date with the latest Sitecore news
  • New to Sitecore? Learn tips and tricks to help you navigate this powerful tool
  • Sitecore pro? Expand your skill set and discover troubleshooting tips
  • Browse open careers and opportunities
  • Get a chance to be featured in upcoming editions
  • Learn our secret handshake
  • And more!
Sitecore Snack a newsletter by Fishtank Consulting
 

Meet Dan Cruickshank

President | Sitecore MVP x 11

Dan is the founder of Fishtank. He's a multi-time Sitecore MVP and Coveo MVP award winner. Outside of technology, he is widely considered to be a top 3 father (routinely receiving "Father of the Year" accolades from his family) and past his prime on the basketball court.

Connect with Dan