Am 8. February 2010 um 15:41 eingetragen

Manchmal kann es von Vorteil sein, dass eine Indizierung manuell gestartet wird. Dies kann zum Beispiel bei Änderung von kritischen Daten notwendig sein, damit diese entsprechend in der Suchfunktion aktuell sind.

 

Folgendes Snippet startet die inkrementelle Indizierung:

 


string sURL = SPContext.Current.Site.Url;
SearchContext ctx;
 
using (SPSite Site = new SPSite(sURL))
{
     ctx = SearchContext.GetContext(Site);
}
 
Microsoft.Office.Server.Search.Administration.Content sspCnt = new Microsoft.Office.Server.Search.Administration.Content(ctx);
 
string sCntSrc = ConfigurationManager.AppSettings["ContentSources"];               
ContentSourceCollection sspCntCol = sspCnt.ContentSources;
ContentSource contentsource = sspCntCol [sCntSrc];
 
if (cs.CrawlStatus == CrawlStatus.Idle)
     cs.StartIncrementalCrawl();
 
 

 



4 Comments vorhanden.


Kategorien:.NET , C# , Sharepoint , Snippet
Tags:,
Aktionen:E-mail | Permalink | Kick it! | DZone it! | del.icio.us