Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Umbraco - Examine index not updated

Tags:

search

umbraco

I am using Umbraco CMS, and trying to use its site search function that uses Examine.

When I edit a page and publish it, the examine index is not updated, hence search results are always out of date. I have to manually delete the Index folder to update it.

Shouldn't the index be updated automatically everytime you update the content?

like image 321
Aximili Avatar asked Jun 15 '11 01:06

Aximili


1 Answers

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, must republish to index it
  }
}

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, you have to publish twice :S

like image 60
Aximili Avatar answered Oct 07 '22 02:10

Aximili