Anders G. Nordby

Lead Software Engineer at Sopra Steria

EPiServer Find not Indexing on Save/Publish

For some reason, in my current project, EPiServer Find did not trigger on the save and publish events. I thought this should be out-of-the-box, but there might be other stuff happening that blocks this functionality. To solve the problem, I handle Find-indexing during my event handlers:

        internal static void PublishingContent(object sender, ContentEventArgs e)
        {
            // ...more stuff going on here...

            HandleFindIndexing(e.Content);
        }

        internal static void SavingContent(object sender, ContentEventArgs e)
        {
            // ...more stuff going on here...

            HandleFindIndexing(e.Content);
        }

        private static void HandleFindIndexing(IContent content)
        {
            bool shouldIndex;
            var ok = ContentIndexer.Instance.TryShouldIndex(content, out shouldIndex);
            if (ok && shouldIndex)
                ContentIndexer.Instance.Index(content);

            if (!shouldIndex)
                ContentIndexer.Instance.Delete(content);
        }
Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

w

Connecting to %s

%d bloggers like this: