I am creating computed index field for a Multilist field and want to return the items as String in a comma separated list.
However after indexing the Solr, an type text is getting appended to the result.
Configuration:
<field fieldName="category" returnType="string" />
I've also set the fully qualified name of the below class in the configuration.
Code I've written:
public class CategoryMultilistField : IComputedIndexField
{
public string FieldName { get; set; }
public string ReturnType { get; set; }
public virtual object ComputeFieldValue(IIndexable indexable)
{
var scIndexable = indexable as SitecoreIndexableItem;
if(scIndexable != null)
{
var item = (Item)scIndexable;
if(item != null)
{
MultilistField f = item.Fields["category"];
if (f != null)
{
var multilist = f.GetItems();
if (multilist == null || multilist.Length == 0)
return null;
return string.Join(",", multilist.Select(t => t[2]));
}
}
}
return null;
}
}
multilist.Select(t => t[2])
? Shouldn't it bemultilist.Select(t => t.Name)
or something like that?