I'm fighting with the SocialTagManager since a few hours to get something incredibly simple done:
For a given URL Base, give me all tags (from the Tags and Notes) and how often they are used, if the tags start with a certain string.
So I have a Page
http://myportal/SomePage.aspx
that is called with an ID, like
http://myportal/SomePage.aspx?ID=1
http://myportal/SomePage.aspx?ID=2
etc.
Each ID-Page can be tagged by users.
In SQL, this is trivial:
SELECT TOP 10 InputTermLabel, COUNT(InputTermLabel) AS Count
FROM dbo.SocialTags
WHERE InputTermLabel LIKE 'su%' AND UrlID IN (
SELECT UrlID
FROM dbo.Urls
WHERE Url like 'http://myportal/SomePage.aspx%')
GROUP BY InputTermLabel
ORDER BY Count DESC
I can't find a proper way to do this through the Object Model. My current approach is this:
public IDictionary<string, int> GetTags(string query)
{
var result = new Dictionary<string, int>();
using (var site = new SPSite(_siteId, SPUserToken.SystemAccount))
{
var baseUrl = Config.GetSocialUrlBase(site.RootWeb);
var stm = new SocialTagManager(SPServiceContext.GetContext(site));
var terms = stm.GetAllTerms(new Uri(baseUrl),0);
foreach (var term in terms)
{
if (!term.Term.Name.StartsWith(query, StringComparison.InvariantCultureIgnoreCase)) continue;
var tc = stm.GetUrls(term.Term);
int usageCoun
View Complete Post