How to Index guids in Coveo keeping the original format – Part 1

Recently I have been working on a Sitecore project in which I needed to index a sitecore item ID and keep it`s original guid format using Coveo. At indexing time Coveo by default parses all guids to a short guid format.

So for example this guid {FBC05E55-55CA-443C-A3BA-7AE5AA14E2CF} would be transformed to this value fbc05e5555ca443ca3ba7ae5aa14e2cf after indexed.

This is done because there is a converter associated with the type Sitecore.Data.ID(which is the type of the item ID) that will parse that specific type at indexing time from a guid to a short guid.

As I was looking for options I posted a question on Coveo’s answers forum and got the suggestion of creating a custon conversionType and a custom type to get that done.

Understanding conversionTypes

Conversion types are useful to map how Coveo Enterpresie Search handles each type encountered at indexing time(more on the conversion process here). Taking the example described above when Coveo is indexing, it will look for each type of the fields being indexed and convert that type using a converter associated with that type. Complicated right?

You can read it as the following: every time Coveo indexes a guid it will use the converter to make a guid become a short guid. The same goes for other types.

Ok but where is this mapping done? I’m glad you asked 🙂

If you open your Coveo.SearchProvider.config file and look for the conversionTypes section you will notice that the type Sitecore.Data.ID is associated with the conversionType IndexFieldGuidValueConverter. This will make sure that guids become short guids at indexing time.

The conversion itself happens on the method CovertTo. The ConvertTo method for this class is defined like this:

public override object ConvertTo(ITypeDescriptorContext context, CultureInfo culture, object value, Type destinationType)
return ID.Parse((Guid)value).ToShortID().ToString().ToLowerInvariant();

On part 2 of this post I will explain how I to implement a custom converter and have a guid being indexed with its original format.


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s