The following sample code shows how you can create a task to update a search index:
[C#]
using CMS.SiteProvider; using CMS.SettingsProvider; using CMS.CMSHelper; using CMS.TreeEngine;
...
string siteName = CMSContext.CurrentSiteName; string aliasPath = "/News"; string cultureCode = "En-us";
// Tree provider TreeProvider provider = new CMS.TreeEngine.TreeProvider(CMSContext.CurrentUser); // Get document of specified site, aliaspath and culture TreeNode node = provider.SelectSingleNode(siteName, aliasPath, cultureCode);
// If node exists if (node != null) { // Edit and save document node node.DocumentName += " changed"; node.Update();
// Create update task SearchTaskInfoProvider.CreateTask(SearchTaskTypeEnum.Update, PredefinedObjectType.DOCUMENT, SearchHelper.ID_FIELD, node.GetSearchID()); } |