I am using SharePoint 2013 search and getting the list items. The result contains managed metadata which is of format

owstaxidmetadatagsallinfo: L0|#{Guid}|{Text};L0|#{Guid}|{Text}

If I use my custom column name which is a managed property I get the entire hierarcy (like GP0, GTSet ..)

Is there any API to directly convert this data into more readable format or is string manipulation the only way?

2 Answers 2


According to Automatically created managed properties in SharePoint Server 2013:

Data format for Managed Metadata. To query for items tagged with a Managed Metadata field, you have to use the Unique Identifier for each label. You can find the Unique Identifier for each term in a term set in the Term Store Management Tool, on the GENERAL tab. In addition, the data format that is used in the query has to specify from which level in the term set the query should apply. This specification is set by adding one of the following prefixes to the Unique Identifier:

  • To query for all items that are tagged with a term: GP0|#
  • To query for all items that are tagged with a child of term: GPP|#
  • To query for all items that are tagged with a term from a term set: GTSet|#

Based on the provided information, the following example demonstrates how to parse search result for managed metadata field:

using System;
using System.Collections.Generic;
using System.Linq;

namespace SharePoint.Client.Search.Results
    public class TaxonomySearchResultValue
        public TaxonomySearchResultValue()
            TermValues = new List<TermValue>();
            TermSetGuids = new List<Guid>();

        public static TaxonomySearchResultValue Parse(string value)
            var taxVal = new TaxonomySearchResultValue();
            var taxParts = value.Split(';');
            foreach (var taxPart in taxParts)
                if (taxPart.StartsWith("GP0|#")) //Term?
                    var termGuid = new Guid(taxPart.Replace("GP0|#", ""));
                    taxVal.TermValues.Add(new TermValue() { TermGuid = termGuid});
                else if (taxPart.StartsWith("GTSet|#")) //Term Set?
                    taxVal.TermSetGuids.Add(new Guid(taxPart.Replace("GTSet|#", "")));
                else if (taxPart.StartsWith("L0|#")) //Term with label?
                    var termParts = taxPart.Replace("L0|#0", "").Split('|');
                    var termGuid = new Guid(termParts[0]);
                    var termLabel = termParts[1];
                    var termVal = taxVal.TermValues.FirstOrDefault(ti => ti.TermGuid == termGuid);
                    if (termVal == null)
                        taxVal.TermValues.Add(new TermValue() {TermGuid = termGuid, Label = termLabel});
                        termVal.Label = termLabel;

            return taxVal;

        public IList<TermValue> TermValues { get; set; }

        public IList<Guid> TermSetGuids { get; set; }


    public class TermValue
        public string Label { get; set; }

        public Guid TermGuid { get; set; }


var taxValue = "L0|#09d72d96c-407f-4e45-b2e6-9361faf5808a|Office;L0|#0ac96f075-b7d2-4e90-8dc2-da8875f395fc|Home";
var taxInfo = TaxonomySearchResultValue.Parse(taxValue);

I think you can use TaxonomyFieldValueCollection for this.


var taxCollection = new TaxonomyFieldValueCollection("wss Id;#Label|Guid");

foreach(TaxonomyFieldValue value in taxCollection){
   var label = value.Label;
  • 1
    Wrong format. This will not work.
    – lapsus
    Commented Jan 20, 2015 at 7:58

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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