Take the 2-minute tour ×
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It's 100% free, no registration required.

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

share|improve this question
add comment

1 Answer 1

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
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.