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 don't think (looking at the SI4T wiki) that I can access Metadata from my SearchIndexCustomFieldMap
field in my Component Template?
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
.
Not really sure what approach to take from here?
We are using Tridion 2011 SP1 HR1