【发布时间】:2013-02-25 20:31:30
【问题描述】:
需要帮助来完成我的 C# 程序。我的农场中有四个内容源。如果内容源空闲,我需要获取所有内容源并开始完全爬取。
最好的方法是什么。请有人给我指出一篇关于 Sharepoint 搜索对象模型/快速搜索对象模型的好文章。
【问题讨论】:
标签: sharepoint sharepoint-2010 sharepoint-api fastsearch
需要帮助来完成我的 C# 程序。我的农场中有四个内容源。如果内容源空闲,我需要获取所有内容源并开始完全爬取。
最好的方法是什么。请有人给我指出一篇关于 Sharepoint 搜索对象模型/快速搜索对象模型的好文章。
【问题讨论】:
标签: sharepoint sharepoint-2010 sharepoint-api fastsearch
你可以像这样得到所有ContentSourceCollection:
/*
Replace <SiteName> with the name of a site using the SSP
*/
string strURL = "http://<SiteName>";
SearchContext context;
using (SPSite site = new SPSite(strURL))
{
context = SearchContext.GetContext(site);
}
Content sspContent = new Content(context);
ContentSourceCollection sspContentSources = sspContent.ContentSources;
foreach (ContentSource cs in sspContentSources)
{
Console.WriteLine("NAME: " + cs.Name + " ID: " + cs.Id);
}
如果你想指定ContentSource 比:
string strContentSourceName = "FASTQuerySSA"; //which indicates the name of the content source to retrieve
ContentSource cs = sspContentSources[strContentSourceName];
Console.WriteLine("Crawl Status = " + cs.CrawlStatus);
Console.WriteLine("Crawl started at: " + cs.CrawlStarted.ToString());
Console.WriteLine("Crawl completed at: " + cs.CrawlCompleted.ToString());
cs.StartIncrementalCrawl();
break;
cs.StartFullCrawl();
break;
cs.PauseCrawl();
break;
cs.StopCrawl();
break;
更多详情请看这里:http://msdn.microsoft.com/en-us/library/aa679491%28v=office.12%29.aspx
这里有一些代码用于枚举您场中的所有搜索服务应用程序。它确实包括所有这些,包括 FAST 内容和 FAST 查询:
SearchService s = new SearchService("OSearch14", SPFarm.Local);
foreach (SearchServiceApplication ssa in s.SearchApplications)
{
//do something with the proxy here
}
【讨论】: