我已经能够为SP13人员创建自定义结果源,如下所示:
var fedManager = new FederationManager(application);
var owner = new SearchObjectOwner(SearchObjectLevel.SPSite, site.RootWeb);
var peopleSource = fedManager.GetSourceByName(Consts.ResultSources.PeopleSource, owner);
QueryTransformProperties queryProperties = new QueryTransformProperties();
SortCollection sortCollection = new SortCollection();
sortCollection.Add("PreferredName", SortDirection.Ascending);
queryProperties["SortList"] = sortCollection;
var currentResultSource = fedManager.CreateSource(owner);
currentResultSource.Name = sourceName;
currentResultSource.ProviderId = fedManager.ListProviders()["Local SharePoint Provider"].Id;
currentResultSource.CreateQueryTransform(queryProperties, "{?{searchTerms} ContentClass=urn:content-class:SPSPeople}");
currentResultSource.Commit();
这很好用但我仍然需要在“类型”部分中手动设置“人物搜索结果”而不是默认的“SharePoint搜索结果”。我可以通过编程方式进行吗? 谢谢。
答案 0 :(得分:1)