Creating an indexing task

  Previous topic Next topic JavaScript is required for the print function Mail us feedback on this topic! Mail us feedback on this topic!  

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());

        }

 

Page url: http://devnet.kentico.com/docs/5_5r2/devguide/index.html?api_smart_search_creating_an_indexing_task.htm