Skip to main content
4 of 4
replaced http://tridion.stackexchange.com/ with https://tridion.stackexchange.com/

Indexing specific Keyword Metadata fields

I'm trying to use SI4T to index the value of a Keyword Metadata field into Solr. I've been using SI4T to index DCPs (which I posted a question about not so long ago here). The DCPs are going into Solr fine, but I'm not too sure how to check if a Keyword field contains Metadata only to specifically index a certain field. I kind of know what options I have but what I have tried currently doesn't work.

I don't think (looking at the SI4T wiki) that I can access Metadata from my SearchIndexCustomFieldMap field in my Component Template? I did try doing this but it didn't work, no errors just didn't index the Keyword Metadata field.

I have had a look at the ProcessCustomField method in the FieldsProcessor class which seems to check for a KeywordField and if one is found it indexes it's Id, code snippet of this is shown below:

 public virtual void ProcessCustomField(ItemField field, FieldProcessorSettings settings = null)
    {
        IndexField targetField = settings.CustomFieldTarget(field.Name);
        IList<string> values = new List<string>();
        if (field is KeywordField)
        {
            values = ((KeywordField)field).Values.Select(k => k.Id.ItemId.ToString()).ToList();
        }
        else if (field is ComponentLinkField)
        {
            values = ((ComponentLinkField)field).Values.Select(c => c.Id.ItemId.ToString()).ToList();
        }
        else if (field is DateField)
        {
            values = ((DateField)field).Values.Select(d => d.ToString("o") + "Z").ToList();
        }
        else if (field is NumberField)
        {
            values = ((NumberField)field).Values.Select(n => n.ToString()).ToList();
        }
        else if (field is TextField)
        {
            values = ((TextField)field).Values;
        }
        AddToData(values, (field is XhtmlField), targetField);
    }

Now what I was trying to do with the above is get the Xml of the Keyword Metadata and add it's value to values. But I'm not sure if this is the right approach to take?

We are using Tridion 2011 SP1 HR1.

Ibrar Hussain
  • 2.3k
  • 14
  • 29