Gravatar for

Question by sdkevorkian, Jun 1, 2018 7:31 PM

unable to change facet value caption for value that has spaces and dashes in Coveo Hive


I am trying to change the caption for a Source facet, similar to in this example:

I am using Coveo Hive which has you add the key value pairs directly in the datasource. I am trying to give a friendlier name to this source: Coveo_web_index - WIN-SFH0CSATQNQ-instancenamehere but am getting "The key is invalid. a key may only contain letters and numbers" error. The example shown has values with spaces and dashes. If I force it and publish, the key becomes "Coveo_web_index___WIN_SFH0CSATQNQ_instancenamehere" in the data-value-vaption for the facet. How can I have this work in sitecore without doing a code change? We want it configurable for each environment since the source will be unique to each.

1 Reply
Gravatar for

Answer by François Lachance-Guillemette, Jun 1, 2018 8:02 PM

This is due to a limitation in the type of Sitecore field that we use for this value.

Unfortunately, Sitecore's "Name Value List" field type does not allow to have other characters than letter and numbers.

To work around this limitation, you could change the type to "Single Line Text" and instead write your mappings like the following:

Coveo_web_index - WIN-SFH0CSATQNQ-instancenamehere=Mapping Value&AnotherSource=Another Mapping

The Coveo for Sitecore Hive serialization engine will parse this attribute as usual.

Since modifying the default template would override your change when upgrading Coveo for Sitecore versions, you could create a template that inherits the `Coveo Facet` one and change the `Conditions` field type to "Single Line Text".


Also, you could create a custom Facet view that hard-codes those values in the `.cshtml` file using

data-value-caption="{ "Coveowebindex - WIN-SFH0CSATQNQ-instancenamehere": "value" }"

Ask a question