【问题标题】:programmatically get SharePoint Fast search content sources以编程方式获取 SharePoint 快速搜索内容源
【发布时间】:2013-02-25 20:31:30
【问题描述】:

需要帮助来完成我的 C# 程序。我的农场中有四个内容源。如果内容源空闲,我需要获取所有内容源并开始完全爬取。

最好的方法是什么。请有人给我指出一篇关于 Sharepoint 搜索对象模型/快速搜索对象模型的好文章。

【问题讨论】:

    标签: sharepoint sharepoint-2010 sharepoint-api fastsearch


    【解决方案1】:

    你可以像这样得到所有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
       }
    

    【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2010-11-26
    • 1970-01-01
    • 2011-08-04
    • 2015-06-21
    • 2013-08-07
    • 2023-02-10
    相关资源
    最近更新 更多