I've been posting about competencies, keywords and user profiles in Sharepoint a while ago and I've promised some code, so here is the "Keywords and Best Bets" part (User Profiles will follow up).
Keywords are basically just Portal Area's, so creating keywords is a matter of creating an Area in the keywords Area. This Area is a special Area and can be retrieved using the Object Model.
|
// Get the current portal context Microsoft.SharePoint.Portal.Topology.TopologyManager topologyManager = new TopologyManager();
Uri uri = "[portal url]";
PortalSiteCollection sites = topologyManager.PortalSites;
PortalContext portalContext = PortalApplication.GetContext(sites[uri]);
// Get the guid of the keyword area
Guid keywordGuid = AreaManager.GetSystemAreaGuid(portalContext, SystemArea.Keyword);
Area keywordArea = AreaManager.GetArea(portalContext, keywordGuid);
keywordArea.Areas.AddArea("[keyword]"); keywordArea.Update(); |
It's quite simple as you can see, but what about Best Bets? Keywords are just Area's in a special keyword Area, Best Bets are the Area Listings in this Area. So, creating a Best Bet is about the same code when creating Area Listings in an Area.
|
// Create guid array that represents the audiences Guid[] guidAudiences = new Guid[] { new Guid("00000000-0000-0000-0000-000000000000") }; AreaListing myListing = keywordArea.Listings.AddListing("[Title]","[Description]",ListingType.Person,"[url]",guidAudiences);
myListing.Update(ListingUpdateBehavior.SubmitToSiteRegistry);
keywordArea.Update();
|
This way you're able to create a structure of Keywords and Best Bets dynamically and have influence on the search results. In my opinion this method is quite underestimated because it can improve a lot of efficiency in Information Worker organisations.