Is there an API to determine if Sharepoint/MOSS/SearchServer is currently crawling a particular content source?


Here is how you can determine the crawling status for SharePoint 2010:

SearchService searchService = SearchService.Service;
// replace "Search Service Application" with actual Search Service Application Name
SearchServiceApplication searchApp = 
          searchService.SearchApplications.GetValue<SearchServiceApplication>("Search Service Application"); 

Content content = new Content(searchApp);

foreach (ContentSource contentSource in content.ContentSources)
       Console.WriteLine(string.Format("{0}: {1}", contentSource.Name, contentSource.CrawlStatus));

The content source crawl status is retrieved via ContentSource class. It is available for both SharePoint 2010 and SharePoint 2007. You can check MSDN sample for SharePoint 2007 here.

In 2010, it's even easier with PowerShell:

Get-SPEnterpriseSearchServiceApplication | Get-SPEnterpriseSearchCrawlContentSource

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy