简体   繁体   中英

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?

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

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM