I'm retrieving a taxonomy field from a search request in a Display Template. The content of the field looks like this:




So now I want to render the system name ("The-term-name") and the label of the term. What is the best approach to do that? Do I have to parse the string value on my own?

2 Answers 2


Assuming you only want to parse the returned term and not lookup alternate labels and such you can use the built-in $getItemValue function. It takes the context and the mapped name of your managed property:

$getItemValue(ctx, mappedManagedProperty')

The mapping is the name you specify in the ManagedPropertyMapping attribute within the display template. Say your display template specified these mappings:

<mso:ManagedPropertyMapping msdt:dt="string">
  'Subject': 'owstaxIdSubject'

Where owstaxIdSubject is a taxonomy field managed property with a value like so:


You would write this:

$getItemValue(ctx, 'Subject')

to render something like this:


You can get the term and its information by Managed Metadata API (very slow) or lookup in the local list (unsupported). But I'd make a REST call to the item and get directly this fields display value. In that way you do not need to handle different field types and scenarios.

  • I already have the term field at hand. It's an JavaScript object of type "Srch.ValueInfo". And the only useful stuff is the property "InputValue" as described in my question. When I want to get the display name I have to use the Taxonomy API, I think that's right. But what's the best way to get the system name that's already contained in "inputValue"? IsN't there any build in function or have I do the parsing on my own? Am I the first person that is obtaining a taxonomy field via a Search Web Part with Display Template?! Mar 4, 2016 at 8:24

Your Answer

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

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