TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
sumit kumar
NA
158
2.4k
Query Site Collection Level Result Source in C#
Nov 30 2015 3:00 AM
I have created a result source at site collection level from SharePoint UI but when trying to get result source in code it's not coming at all only default result source which SharePoint provides those only coming. Is there any other way to refer custom result source in C# in SharePoint 2013. Below is the code which I am trying:
string resultSourceId = string.Empty;
SearchQueryAndSiteSettingsServiceProxy settingsProxy = SPFarm.Local.ServiceProxies.GetValue<SearchQueryAndSiteSettingsServiceProxy>();
SearchServiceApplicationProxy searchProxy = settingsProxy.ApplicationProxies.GetValue<SearchServiceApplicationProxy>("Search Service Application");
SearchObjectOwner siteCollectionOwner = new SearchObjectOwner(SearchObjectLevel.SPSite, web);
SourceRecord siteCollectionResultSource = searchProxy.GetResultSourceByName("CustomResultSourceName", siteCollectionOwner);
string resultSourceId = siteCollectionResultSource.Id.ToString();
Reply
Answers (
1
)
Only Content controls are allowed directly in a content page
Migrate 2007 Share Point to 2013 Share Point & to new server