as treelist values is being indexed in solr as IDs so I needed to create a computed index field for it to read the names, as follows

namespace TAMM.SXA.Feature.ServiceDetails.ComputedIndexFields
    public class FAQRelatedADGEsField : AbstractComputedIndexField
        public override object ComputeFieldValue(IIndexable indexable)

            Item item = indexable as SitecoreIndexableItem;

            StringBuilder ADGEsNameList = new StringBuilder();

            if (item == null)
                return null;

            if (item.TemplateName == "FAQ")
                Database currentDatabase = item.Database;
                if (item.Fields["FAQ Related ADGE"].HasValue)
                    var ADGEsIDs = item.Fields["FAQ Related ADGE"].Value.ToString().Split(new[] { '|' },
                    foreach (var ADGEID in ADGEsIDs)
                        ID FAQADGEID = new ID(ADGEID);
                        Item FAQADGEItem = currentDatabase.GetItem(FAQADGEID, item.Language);
                        if (FAQADGEItem != null)

                            ADGEsNameList.Append(FAQADGEItem.Name.ToString() + ",");

            return ADGEsNameList;

I tried to register it as stringCollection as follows

<configuration xmlns:patch="http://www.sitecore.net/xmlconfig/" xmlns:role="http://www.sitecore.net/xmlconfig/role/" xmlns:search="http://www.sitecore.net/xmlconfig/search/">
  <sitecore role:require="Standalone or ContentManagement or ContentDelivery" search:require="solr">
      <!-- Configuration sections for indexes -->
        <!-- If an index has no configuration specified, it will use the configuration below. The configuration is not merged if the index also has
             configuration, it is either this configuration or the index configuration. -->
        <defaultSolrIndexConfiguration type="Sitecore.ContentSearch.SolrProvider.SolrIndexConfiguration, Sitecore.ContentSearch.SolrProvider">
          <documentOptions type="Sitecore.ContentSearch.SolrProvider.SolrDocumentBuilderOptions, Sitecore.ContentSearch.SolrProvider">
            <fields hint="raw:AddComputedIndexField">
              <field fieldName="FAQRelatedADGEsField" returnType="stringCollection">TAMM.SXA.Feature.ServiceDetails.ComputedIndexFields.FAQRelatedADGEsField,TAMM.SXA.Feature.ServiceDetails</field>

but when querying Solr I get the field like this

"faqrelatedadgesfield_sm":["First Entity,Second Entity,"],

the purpose is to use this field in a facet to be displayed as checklist filter

can anyone help to get the computed index right?

  • @Gatogordo yes it's SXA enviroment, but the main goal is translating treelist index from list of IDs to list of Names into a new computed field – Tareq Mansour Sep 29 '18 at 13:44
  • Reason I had to be sure it was SXA (althoughh your namespace gave it away) was to lead you to the answer(s) in a recently asked question solving your problem without custom coding ;) – Gatogordo Sep 29 '18 at 13:47
  • @Gatogordo This looks promising, thank you, I will try and update you with my result – Tareq Mansour Sep 29 '18 at 13:53
  • @Gatogordo Do I have to change treelist to tagtreelist?, as I can't change that – Tareq Mansour Sep 29 '18 at 14:38
  • Might depend on the solution.. I haven't tried the solution from Dawid yet - mine works for all link fields. – Gatogordo Sep 29 '18 at 14:44

You could (and maybe should) use the options that SXA gives you. The are described in the answers here: Filter (Checklist) component shows ids of facets not values in SXA (one of them is actually the code you are trying to write but which is already written by the SXA team).

If you do really want to write your own code, return a collection of strings (IEnumerable or List) instead of a single string with comma's.

Not the answer you're looking for? Browse other questions tagged or ask your own question.