Copied to clipboard

Flag this post as spam?

This post will be reported to the moderators as potential spam to be looked at


  • Thomas Lee 38 posts 79 karma points
    May 20, 2015 @ 08:37
    Thomas Lee
    0

    Umbraco 7 Examine - Parent.Name

    Hi Guys, 

    Can someone tell me if this is possible?

    <IndexUserFields>
    <add Name="academicLevel"/>      
    <add Name="school" EnableSorting="true"/>    
    <add Name="ptft" />  
    <add Name="parent.name"/>
    </IndexUserFields>
    <IncludeNodeTypes>
           <add Name="course"/>      
    </IncludeNodeTypes>

    Please let me know. 

    Thanks in advance!

  • TikTakToe 60 posts 102 karma points
    May 20, 2015 @ 14:40
    TikTakToe
    0

    hi

    not sure if that would work (but happy to be corrected as every days a school day!), but i normally add those as custom index fields in the GatheringNodeDataHandler event like so:

    protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
    {
        ExamineManager.Instance.IndexProviderCollection["ArticleIndexer"].GatheringNodeData += GatheringNodeDataHandler_Article;
    
    }
    
    
    
    private void GatheringNodeDataHandler_Article(object sender, IndexingNodeDataEventArgs e)
    {
        try
        {
    
            var currentItem = Helper.TypedContent(e.NodeId);
    
            e.Fields.Add("parent", currentItem.Parent.Name);
    
    
        }
        catch (Exception ex)
        {
            LogHelper.Error<ExamineEvents>(
                string.Format("Exception: {0} - StackTrace: {1}", ex.Message, ex.StackTrace), ex);
        }
    }
    

    When the index gets built, the custom field gets added in and will be available for searching. Its a great way of adding custom data to your index, such as MNTP node ids to actual names etc.

    enjoy!

    Ian

  • Thomas Lee 38 posts 79 karma points
    Jun 04, 2015 @ 09:30
    Thomas Lee
    0

    I am so new, i have no idea where to add anything. ;((((

     

    Create a class in APP_Code? 

    Can anyone help me =(((((((((((((((((

Please Sign in or register to post replies

Write your reply to:

Draft