Copied to clipboard

Flag this post as spam?

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


  • Aximili 177 posts 278 karma points
    Jun 16, 2011 @ 02:58
    Aximili
    0

    Document.AfterPublish and indexing

    I wrote a class that updates the index on publish.

    using umbraco.BusinessLogic;
    using umbraco.cms.businesslogic.web;
    using Examine;
    
    public class UmbracoEvents: ApplicationBase
    {
      /// <summary>Constructor</summary>
      public UmbracoEvents()
      {
        Document.AfterPublish += new Document.PublishEventHandler(Document_AfterPublish);
      }
    
      private void Document_AfterPublish(Document sender, umbraco.cms.businesslogic.PublishEventArgs e)
      {
        // Rebuild SiteSearchIndexer
        ExamineManager.Instance.IndexProviderCollection["SiteSearchIndexer"].RebuildIndex(); // Unfortunately this doesn't index the latest change
      }
    }
    

    However it doesn't get the latest change even if it is supposed to run "after" publish. So, to make the search results up to date, I have to publish twice.

    Why is that happening? I want the index to be updated when the user publish a content. Did I do anything wrong?

Please Sign in or register to post replies

Write your reply to:

Draft