SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Just like I can go to Central Administration > Application Management > Manage Service Applications > Managed Metadata Service and see the list of existing terms under the Keywords termset I'd like to do this programatically in C#.

So what I need to do is access somekind of Managed Metadata Service API, open the Keywords termset (which is the default termset for Entreprise Keywords) and then get a list of all the existing keywords that are applied to at least one document. For each term I'd like to know to which document is applied so then I can run some process to know which terms are most frequently used and which are most infrequently used.

Forgot to mention this is for SharePoint 2010 Server.

share|improve this question
up vote 2 down vote accepted

You will need to reference the Microsoft.SharePoint.Taxonomy assembly. Then you can open a Taxonomy Session and do what you need to do.

var site = SPContext.Current.Site;
var taxonomySession = new TaxonomySession(site);
var termSet = taxonomySession.DefaultKeywordsTermStore.KeywordsTermSet;


MSDN has this documented in detail:

share|improve this answer
Yes, I've already done that... but once I have a Term I can't find how to get the documents that have this term as enterprise keyword. I'm thinking this is not possible from these Taxonomy classes. – emzero Apr 9 '13 at 23:32
You are correct. From this side, there are no records of when the terms are used. You would need to iterate through every SPList of every SPWeb of every SPSite of every SPWebApplication to look for metadata fields that contain your values. – John Chapman Apr 10 '13 at 14:09

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.