Coveo for Sitecore – Part 2 : custom fields in Coveo index

Unlike Lucene for Sitecore, Coveo’s default configuration does not index all the template fields. However, Coveo for Sitecore makes it very easy to add custom and computed fields to the search index.

How to add fields to index

After creating a new template or field you can add fields to index with the help of Field Map. The field map defines how a field is mapped between Coveo and Sitecore. Here is an example:

<fieldType fieldName="body"  includeForFreeTextSearch="true" settingType="Coveo.Framework.Configuration.FieldConfiguration, Coveo.Framework" />
<fieldType fieldName="heading" isFacet="true" includeForFreeTextSearch="true" settingType="Coveo.Framework.Configuration.FieldConfiguration, Coveo.Framework" />
<fieldType fieldName="description" includeForFreeTextSearch="true" settingType="Coveo.Framework.Configuration.FieldConfiguration, Coveo.Framework" />

There are several configuration options available. The two used in the example above are:

Parameter Name Description Allowed Values Default Value
includeForFreeTextSearch Defines whether full-text search operations can be performed on this field. true / false false
isFacet Defines whether facets can be bound to this field. This is also required for wildcard search. true / false false

View all options

How to add computed fields to index

Computed fields are a good way to process field values before adding them to an index. This is usually done to translate raw values from the database to a meaningful searchable data. A good use case would be to convert the multi-list field values, which stores references to other sitecore items into string values.

For instance, the content pages have a “Tags” field that references items of the template type Tag (Field:Title). The following configuration adds a computed field “parsedtagname” that indexes “Title” field of the tag

<field raw:AddComputedIndexField><field fieldName="parsedtagname" sourceField="Tags" referencedFieldName="Title">Coveo.SearchProvider.ComputedFields.ReferencedFieldComputedField, Coveo.SearchProviderBase</field>

Reference: Creating a computed field for a reference item

Coveo for Sitecore – Part 2 : custom fields in Coveo index

Leave a Reply

Your email address will not be published. Required fields are marked *