How to start an incremental crawl of a search scope from code in SharePoint?
Can this be done? I haven't fo开发者_运维知识库und anything out there that shows a way to do this.
A search scope can not be crawled. A search scope may include or exclude a content source which is actually crawled.
To start a crawl on a content source use the following code:
SearchServiceApplicationProxy proxy = SearchServiceApplicationProxy.GetProxy(SPServiceContext.Current);
Guid appId = ssap.GetSearchServiceApplicationInfo().SearchServiceApplicationId;
SearchServiceApplication app = SearchService.Service.SearchApplications.GetValue<SearchServiceApplication>(appId);
Content content = new Content(app)
ContentSource cs = content.ContentSources["<content source name>"];
cs.StartIncrementalCrawl();
// check on cs.CrawlStatus if finished
精彩评论