Portal Engine Questions on portal engine and web parts.
Version 4.x > Portal Engine > Document not found in Search results when added with Kentico API View modes: 
User avatar
Member
Member
zebrashop-hotmail - 9/29/2009 1:24:31 PM
   
Document not found in Search results when added with Kentico API
Hi all,

As explained in the Kentico CMS Developer's Guide I added a News document with the API as shown below. It then shows up under News items, but when I search for 'Obama', NO results occur. However, when I go to CMSDesk, select the newly added news item and press save, it does show up when searching for the term 'Obama'. It looks like the news item wasn't added to the search index when using the API.
What am I doing wrong here? Thanks.

string newsName = "Obama visits Europe";

// create tree provider instance
TreeProvider provider = new TreeProvider(CMSContext.CurrentUser);

// get parent node for new document
CMS.TreeEngine.TreeNode parent = provider.SelectSingleNode(CMSContext.CurrentSiteName, "/News", "en-us");

// create a new tree node
CMS.TreeEngine.TreeNode node = new CMS.TreeEngine.TreeNode("cms.news", provider);

if (parent != null) {
// set document properties
node.NodeName = newsName;
node.NodeAlias = newsName;
node.SetValue("NewsTitle", newsName);
node.SetValue("NewsSummary", "Coming friday Obama will meet with European leaders");
node.SetValue("NewsText", "Some text is going here");
node.SetValue("NewsReleaseDate", DateTime.Now);
node.DocumentCulture = parent.DocumentCulture;

// create new document
node.Insert(parent.NodeID);
}

User avatar
Kentico Developer
Kentico Developer
kentico_zbysekn - 9/29/2009 3:31:35 PM
   
RE:Document not found in Search results when added with Kentico API
Hi,
As you can see in our documentation(Smart search info) when you click on save button in CMSDesk scheduled task is executed which will index newly created item. So you will need to do this also in your code. You can use CMS.Scheduler.TaskInfoProvider.GetTaskInfo(String, String) method to obtain TaskInfo class for scheduled task and then execute it using CMS.Scheduler.SchedulingExecutor.ExecuteTask(TaskInfo).
Best Regards,
Zbysek Nemec