Wednesday, 19 November 2014

How to check the crawl status values for a Content Sources in SharePoint 2010



In this article we will be seeing how to check the crawl status values for content sources in SharePoint 2010.

If you go to Central Administration => Application Management => Manage service applications => Search Service Application => Crawling => Content Sources you could see all the content sources.

1.gif

To check the crawl status values for a content source

  • Open Visual Studio 2010.
  • Go to File => New => Project.
  • Select Console Application from the installed templates.
  • Enter the Name and click Ok.
  • Add the following references.

    o Microsoft.SharePoint.dll
    o Microsoft.Office.Server.dll
    o Microsoft.Office.Server.Search.dll
     
  • Add the following namespaces.

    o using Microsoft.Office.Server.Search.Administration;
    o using Microsoft.Office.Server;
    o using Microsoft.SharePoint;
     
  • Replace the code with the following.

    //  search service application name   
                string ssaName ="Search Service Application";
                SearchContext context =SearchContext.GetContext(ssaName);
    Content ssaContent = new Content(context);
                ContentSourceCollection ssaContentSources = ssaContent.ContentSources;
                   ContentSource cs = ssaContentSources["Local SharePoint Sites"];
                Console.WriteLine(cs.CrawlCompleted.ToString());
                Console.WriteLine(cs.CrawlStarted.ToString());
                Console.WriteLine(cs.CrawlStatus);
                Console.WriteLine(cs.CrawlPriority);


     
  • Build the solution.
  • Hit F5.

    2.gif
     


Reference:

http://www.c-sharpcorner.com/uploadfile/anavijai/how-to-check-the-crawl-status-values-for-a-content-sources-in-sharepoint-2010/

No comments:

Post a Comment