0
votes

I would like to know how Solr indexes general link field or do we need to create computed index field for this ?

I have a helper class which is inheriting from SearchResultItem and it has below index field.

    [IndexField("Call To Action")]

    public LinkField CallToAction { get; set; }

This field is a general link field in sitecore.

Below is the search code which retrieves all the Event_card values except CallToAction (i.e. Always null). if I convert the field type from Link to string , I get the entire general link raw value which is difficult to parse at view and make it editable through glass mapper.

if (result.TotalSearchResults != 0)

            {

                //Load Event card data to be displayed on page

                var resultItems =

                    result.Select(c => new Event_Card

                    {

                        Headline = c.Document.Headline,

                        Start_Date=c.Document.StartDate,

                        Content=c.Document.ContentData,

                        Call_To_Action=c.Document.CallToAction  // this is always null                 

                    });

            }

Here is my Entity class related to Event_Card

Event_Card

[global::System.CodeDom.Compiler.GeneratedCodeAttribute("Team Development for Sitecore - GlassItem.tt", "1.0")]

    [SitecoreField(IEvent_CardConstants.Call_To_ActionFieldName)] 



    public virtual Link Call_To_Action { get; set; }

IEvent_Card

[SitecoreField(IEvent_CardConstants.Call_To_ActionFieldName)]

    Link Call_To_Action { get; set; }

public static partial class IEvent_CardConstants

{

public static readonly ID Call_To_ActionFieldId = new ID("4c296a05-d05f-47c5-8934-8801bec5be85");

    public const string Call_To_ActionFieldName = "Call To Action";

}

Can anybody let me know How can I achieve this. If we need to use computed field , an example would be of great help.

Thanks in Advance !

1

1 Answers

-1
votes

I just quickly browsed and found useful link for you.

Map sitecore 8 general link field from Index

I think this Stack overflow question describes what you are saying and there is a link which might be helpful to you.