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:




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";



            // Create update task

          SearchTaskInfoProvider.CreateTask(SearchTaskTypeEnum.Update, PredefinedObjectType.DOCUMENT, SearchHelper.ID_FIELD, node.GetSearchID());



Page url: