I created several custom tags in my TagRepository folder that work great, but when I look at them in a bucket they display as GUIDs. After some research, I implemented a computed index field that displays the tags as their actual text.
However, the problem I am running into is the fact that the computed index field delimits spaces as separate tags (for example "Evening MBA" gets rendered as "Evening" and "MBA" separately).
Supposedly a Lucene analyzer should be able to fix this but it doesn't seem to work and I'm not seeing any relevant errors in my Sitecore logs.
My included config:
<?xml version="1.0" encoding="utf-8" ?>
<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/">
<sitecore>
<contentSearch>
<indexConfigurations>
<defaultLuceneIndexConfiguration>
<fields hint="raw:AddComputedIndexField">
<field fieldName="tagsfacet" storageType="yes" indexType="untokenized" returnType="string">WSB.CMS.Utilities.ComputedIndexFields, WSB.CMS.Utilities</field>
</fields>
<fieldMap>
<fieldNames hint="raw:AddFieldByFieldName">
<field fieldName="tagsfacet" storageType="YES" indexType="TOKENIZED" vectorType="NO" boost="1f" type="System.String" settingType="Sitecore.ContentSearch.LuceneProvider.LuceneSearchFieldConfiguration, Sitecore.ContentSearch.LuceneProvider">
<Analyzer type="Sitecore.ContentSearch.LuceneProvider.Analyzers.LowerCaseKeywordAnalyzer, Sitecore.ContentSearch.LuceneProvider" />
</field>
</fieldNames>
</fieldMap>
</defaultLuceneIndexConfiguration>
</indexConfigurations>
</contentSearch>
</sitecore>
</configuration>
My Computed Index Field:
class ComputedIndexFields : IComputedIndexField
{
public string FieldName { get; set; }
public string ReturnType { get; set; }
private static readonly ID Semantics = new ID("{A14F1B0C-4384-49EC-8790-28A440F3670C}");
public object ComputeFieldValue(IIndexable indexable)
{
var indexableItem = indexable as SitecoreIndexableItem;
return indexableItem == null ? null : indexableItem.Item.GetMultiListValues(Semantics).Select(tag => tag.DisplayName).ToList();
}
}
public static class HelperMethods
{
public static IEnumerable<Item> GetMultiListValues(this Item item, ID fieldId)
{
return (new MultilistField(item.Fields[fieldId])).GetItems();
}
}