Using Managed Metadata Service in SharePoint

Managed Meta Data Service and Term Store Management Tool:

Managed MetaData Service allows us to use content types and managed metadata connections across web applications and site collections.

In order to create User Managed Metadata and term sets we need to enable the Managed Meta Data Web Service.

Managed Metadata Web Service is a service application like any other service application (e.g. Search Service or Excel Service).

To Enable it, go to Central Administration-> System Settings ->Manage Services on Server->Managed Metadata Web Service and verify the service is started. If it isn’t, click start.

When we start the Manage Metadata Web service, SharePoint automatically creates a Managed Metadata Service Connection. The service identifies the database to be used as the term store, and the connection provides access to the service.

To add Groups and term sets in the Managed Metadata Service you need to be a Term Store Administrator.

How managed Meta Data Service is Stored in SharePoint:

Managed Metadata Service is stored in a separate Database apart from the normal content database as it is a service application. The Database name is usually stored as a Managed Metadata Service_<Guid >.

managed metadata service

These settings (i.e. the database where the term stores should be stored) can be configured in the Central administration->Application Management-> Manage Service Application-> Managed Metadata Service. Click on the row and click Properties at the top of the window.

managed metadata service properties tab

create new managed metadata service dashboard

The Service connection specifies whether it uses this service application as a default storage location for keywords, or uses it as a default storage location for Column Specific Term Sets. To configure the connection settings click on the row in Central administration->Application Management-> Manage Service Application that corresponds to the Manage Metadata Service connections and click Properties.

Edit managed metadata service connection tab

Note: We might think both Managed terms and Enterprise Keywords are the same but Managed terms are usually pre-defined and can only be created by users with the appropriate permissions; and they are often organized into a hierarchy. Enterprise Keywords are simply words or phrases that have been added to the SharePoint Server 2010 items. All enterprise keywords are part of a single, non-hierarchical term set called the keyword set.

How to Create Groups, Term Sets and the Terms
The following are key things we need to consider before creating Terms Sets and Terms:

  • SharePoint Allows a maximum number of seven levels on nested terms in a term set (i.e. terms can be nested up to seven levels deep within a Term Store).
  • We can have a maximum of 1000 term sets in a term store.
  • A term set can have a maximum of 30,000 terms.
  • There can be a total of 1,000,000 items in a term store. An item can be either a term or a term set. So the total number of term and term sets cannot exceed 1,000,000. We cannot have both a maximum number of term sets and a maximum number of terms simultaneously in a Term Store.

Usually the Groups, Term Sets and the Terms are created through the Term Store Management Tool. (Central administration->Application Management-> Manage Service Application-> Click on Managed Metadata Service).

We can also import a Term Set from a CSV. The format for a CSV file is given below:

Term Set name, Term Set Description, LCID, Available for Tagging, Term Description, Level 1 Term, Level 2 Term ,Level 3 Term.

We can also create the Groups, Terms Sets and Terms programmatically.

Sample Code:

How to Move a Term Set/Group from one SharePoint Farm to Another

We can move the Term Set/Group from one SharePoint farm to another in the following way:

SharePoint Management Shell:

The following is the syntax to Export a term set through Power Shell:

$mmsAppId= “App ID Guid Placeholder”

$mmsproxy = Get-SPServiceApplicationProxy | ?{$_.TypeName -eq “ExportTaxonomyProxyName”};

Export-SPMetadataWebServicePartitionData -Identity $mmsAppId -ServiceProxy $mmsproxy -Path “Path to save Exported file placeholder”

EX: Export-SPMetadataWebServicePartitionData -Identity $mmsAppId -ServiceProxy $mmsproxy -Path \\location\exportfile.bak;

And the following is syntax to Import a term set:

$mmsAppId= “App ID Guid Placeholder”

$mmsproxy = Get-SPServiceApplicationProxy -Identity “Proxy ID Guid Placeholder”

Import-SPMetadataWebServicePartitionData -Identity $mmsAppId -ServiceProxy $mmsproxy -Path “Exported file’s path placeholder” -OverwriteExisting;

Ex: Import-SPMetadataWebServicePartitionData -Identity $mms2 -ServiceProxy $mms2proxy –path \\location\exportfile.bak -OverwriteExisting;

Third Part Tool (CodePlex):

We need to specify the SharePoint Site where the Group resides. And we also need to specify the Group name that needs to be exported and the CSV files folder where the CSV files are to be created. Once this is completed, we click on Export. This creates a CSV file with the name of the Term Set in the group. This tool creates one CSV files for each term set in the group.

bulk csv importer in SharePoint

Then we can import the generated CSV files to the new environment.

Through .Net Code:

We can also export and import the Terms and Term Sets programmatically.

The following are the steps to export the groups and term sets in the Managed Metadata Service:

  1. Create the SPSite object which links to the managed service application we want to export.
  2. SPSite site = new SPSite(siteUrl)

  3. Create a TaxonomySession and pass in the SPSite we created in step 1 as a parameter.
  4. TaxonomySession session = new TaxonomySession(site);

  5. Retrieve TermStore collection from the session object created in step 2.
  6. TermStore MetadataTermStore = session.TermStores[managedMetadataServiceName]

  7. Iterate through terms collection and extract to an XML file.
  8.    foreach (Group g in MetadataTermStore.Groups)

                    {

                       // some code…….

       }

Sample code:

To Import the groups and Term Sets:

  1. Create the SPSite object which links to the managed service application we wish to export.
  2. Create a TaxonomySession and pass in SPSite we created in step 1 as parameter.
  3. Retrieve TermStore collection from the session object we created in step 2.
  4. Iterate through extracted xml and import into the term store, then submit.

Sample Code:

Planning and Organizing Managed Metadata – Best Practices:

Planning and organizing managed metadata involves the following steps:

  • Identify term sets.
  • Identify the owner of each term set.
  • Determine term set groups.
  • Define term sets.

Identify term Sets

Not all metadata is managed metadata (e.g. a term set).  The tables below provide suggestions about when the metadata that is identified is likely to be managed metadata. If it is not clear whether to create a term set for a metadata item then it is best not to create a term set.

Is the potential metadata…

… likely to be managed metadata?

Is something where a user will select a valid value Yes
Represents information that is likely to be used multiple times Yes
Has valid values that can be organized hierarchically Yes
Includes synonyms or abbreviations that should be aggregated Yes
Can be applied in one language, but might be viewed in other languages Yes
Is represented by a built-in column (such as “last modified date”) No
Has an infinite number of valid values No
Has different valid values in each location that it is used (such as different values for the “version” attribute depending on which product team’s site the item appears in) No (or, if it is represented by managed metadata, it can be planned and managed at the site level.)
Has only “yes” and “no” as valid values No

 

Once the term sets are identified, record the term sets planning work sheet along with a brief description of each term set.

Identify Term Set Owners

For each term set, you will have to determine an owner. The owner can then define the terms in the term set. If the term set will be used across the organization, or if the terms in the term set will be strictly controlled, it is likely that there is already a group that manages the information. This group will probably manage the term set. If the information is not strictly controlled, you might have to nominate a person to own the term set and to periodically clean up the terms.

Record the owner of each term set in the term set planning worksheet.

Define Term Sets

After each term set and its owners are identified the next step is to define each term set using the questions below.

  • What are the terms in the term set?
  • How should the terms be organized?
  • Who should be permitted to add terms to the term set?

Use the guidance in the following sections to define and organize the terms, and to determine whether the term set is open or closed.

Identify the Terms

Identify the terms in the term set. If you want to allow multiple terms to represent the same concept include both terms. Identify one term as the primary term, and indicate that the second term is a synonym of the first term.

Organize the Terms

The following example might help you decide how to structure a term set.

  • In a domain, there is likely to be a standard organization. For example, the terms in a term set that represent sales offices might be organized using a geographic hierarchy. The first level terms could be thought of as continents. The second level terms would then be countries. The third level terms would be provinces (or states) within each country. The fourth level terms would be the cities where the offices are located. Because the term set represents sales offices, only the fourth level of terms would be available for tagging.
  • Are there already well known ways that information is organized in your organization? For example, does the folder structure on a file share represent the way that most people would organize information? Is the navigation structure of your intranet portal useful for finding information? You can refer to these examples of how information is currently structured as you organize your term set.
  • If the terms in the term set are merely a list that has no clear method of organization, consider organizing them alphabetically. Make the letters of the alphabet the first-level terms, and make the terms themselves the second-level terms. If the term set is too large for that structure, you could create a second level of alphabetical organization (for example, “AA – AF”, “AG – AI”, “AJ – AR”, and “AS – AZ”), and include the terms themselves at the third level. The terms in the levels that are merely for alphabetizing would be marked as unavailable for tagging.
  • Identify Who Can Add Terms

    Anyone can add a new term to an open term set. Only people who were identified as contributors to a term set group can add terms to a closed term set in the group. For example, a term set that represents cost centers would probably be closed. A term set that represents contributors to a charity might be open.

    The following is a template for a Metadata Planning Worksheet:

    Fill this worksheet by using the following topics:
    Plan terms and term sets
     
    Prepared by:  
    Date:  
    Term set Description Owner Group
           
           
           

     

    The following is a template for Term Set Planning worksheet:

    Fill out this worksheet by using the following topics:
    Plan terms and term sets
     
    Prepared by:   Date:  
    Term Set:  
    Description:  
    Owner:  
    Open/closed:  
    L1 L2 L3 L4 L5 L6 L7 Description Available Synonym of
                       
                       
                       

     

    **Note: When a site is created as a blank site the term store management will not appear. In this case, to make the term store management appear we need to activate the following feature through stsadm:

    stsadm -o activatefeature -id 73EF14B1-13A9-416b-A9B5-ECECA2B0604C -url <URL> –force

    March 10, 2014