Aximili
Aximili

Reputation: 29444

Umbraco - Examine index not updated

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?

Upvotes: 5

Views: 6242

Answers (2)

Patrick Demers
Patrick Demers

Reputation: 93

You can manually update the index by using Examine Dashboard.

To automatically rebuild indexes on app startup, you could add this line into ExamineIndex.config located in config directory

<Examine RebuildOnAppStart="true">

Indexes should rebuild automatically when you publish/republish a content node. If it doesn't work, you may have configuration problem with Examine.

Upvotes: 2

Aximili
Aximili

Reputation: 29444

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

Upvotes: 4

Related Questions