Skip to main content
replaced http://tridion.stackexchange.com/ with https://tridion.stackexchange.com/
Source Link

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 herehere). 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.

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.

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.

added 181 characters in body
Source Link
Ibrar Hussain
  • 2.3k
  • 14
  • 29

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.

Not really But I'm not sure whatif this is the right approach to take from here?

We are using Tridion 2011 SP1 HR1.

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

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.

Improved title and tagging
Link
Ant P
  • 2k
  • 16
  • 27

Indexing specific Keyword Metadata custom field SI4Tfields

Source Link
Ibrar Hussain
  • 2.3k
  • 14
  • 29
Loading