0

我需要一个控制台应用程序,在其中我需要通过传递一组单词来搜索对话结果源(Sharepoint 2013)并将内容记录在表格中。

要求:sharepoint 2013 的 C# 控制台应用程序,它将每天运行,传递带有单词的查询字符串,例如:microsoft;sharepoint 等。这个查询字符串应该搜索结果源(仅用于对话),因为我们需要监控团队网站、mysite 和 coimmunity 网站上的内容。然后应该把它放在桌子上,上面有这组词的细节。

请让我知道相同的 API。

4

1 回答 1

0

到目前为止我发现了两种方法,我有一个类似的场景: 1. CSOM,但您需要先获取结果源 id 并将其放入您的查询中: var keywordQuery = new KeywordQuery(clientContext);

                keywordQuery.SourceId = new Guid(ConfigurationManager.AppSettings["ResultSourceId"]);

                keywordQuery.QueryText = q;
                keywordQuery.RowLimit = 10;
                keywordQuery.Culture = int.Parse(ConfigurationManager.AppSettings["LCID"]);

                var searchExec = new SearchExecutor(clientContext);

                //var Results = searchExec.ExecuteQuery(keywordQuery);
                var r = keywordQuery.GetQuerySuggestionsWithResults(9, 9, true, true, true, true);

                stopwatch.Restart();
                clientContext.ExecuteQuery();
                stopwatch.Stop();
  1. 服务器端对象模型,这样你就需要在你的 SharePoint 服务器上运行你的应用程序,你可以直接通过代码获取结果源代码: var context = SPServiceContext.GetContext(spSite); var ssap = context.GetDefaultProxy(typeof(SearchServiceApplicationProxy)) as SearchServiceApplicationProxy;

                    var webOwner = new SearchObjectOwner(SearchObjectLevel.SPWeb, spWeb);
                    var webResultSource = ssap.GetResultSourceByName(resultSourceName, webOwner);
    

类似于 CSOM,您可以查询您的结果。

于 2013-12-02T06:42:21.803 回答