Copied to clipboard

Flag this post as spam?

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


  • anthony hall 222 posts 536 karma points
    Oct 19, 2017 @ 10:36
    anthony hall
    0

    Adding custom field to index

    I am adding a custom field to my index, so I can search through tagged multi-node tree picker content. The below works fine, however it appears to be triggered before the content is published making the field content out of date.

    public class AppEvents : IApplicationEventHandler
    {
        public void OnApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
        {
    
            var helper = new UmbracoHelper(UmbracoContext.Current);
    
            ExamineManager.Instance.IndexProviderCollection[GlobalSettings.Indexer.MediaTileIndexer].GatheringNodeData
                += (sender, e) => ExamineEvents.GatheringContentData(sender, e, helper);
        }
    }
    
     public static class ExamineEvents
    {
        public static void GatheringContentData(object sender, IndexingNodeDataEventArgs e, UmbracoHelper helper, List<string> docTypes)
        {
            var content = helper.TypedContent(e.NodeId);
            if (content != null){
    
                var text = content.GetPropertyValue<string>("text");
                // content is not current.
    
            }
        }
    }
    

    As an aside, I've noticed there hasn't been much noise on google about this approach since 2015. Feeling like I'm missing a trick. I'm using 7.71

Please Sign in or register to post replies

Write your reply to:

Draft