Sorting Search Results by Managed Metadata Properties

Elio Struyf

by Elio Struyf on 3/30/2015

Share this:

Article Details

Date Revised:

Applies to:
Managed Metadata, Search, search results, SharePoint Search 2013, Sorting

Most SharePoint environments these days make use of managed metadata. If your site does so and you want to use the managed properties within your search Web Parts, you could experience some strange behaviour when sorting your results based on these managed metadata properties. When using the auto-created managed properties linked to your managed metadata column for sorting, a disorder of your results can occur. In this article, I will explain why it seems that your results are not in the correct order and how you can fix this issue.

For this article I will use a simple list with items that are each mapped with a term (a, b, c, d, …) to highlight the sorting problem.


On a page I added a Content Search Web Part (you can also use a Search Result Web Part if you want) to show only the items of that specific list with test items. Figure 1 shows the output without sorting:

Default sorting results of the Content Search Web Part (CSWP) using managed metadata

Figure 1: Search results without sorting defined

When I configure sorting for the results on my owstaxIdTestTerm managed property (which is the auto-created managed property linked to the managed metadata column), I retrieve the search result order shown in figure 2:

SharePoint sorting using the auto-created managed property

Figure 2: Search results with sorting defined

You can see that the result of the sorting seems to be out of the order you'd expect, but for SharePoint your results are correctly sorted.

This behaviour is related to the managed property you use for configuring your sort order. In this example, the sorting was performed with the owstaxIdTestTerm managed property, which is the auto-created managed property that SharePoint mapped to the crawled property for your column.

Auto-created managed properties for managed metadata columns are, by default, mapped to a crawled property with the following name: ows_taxId_ColumnName. The ows_taxId crawled property contains the following information:

  • GP0: Term ID
  • L0: Term ID + Display value
  • GTSet: Term set ID

Figure 3 shows the same result set with the internal values:

SharePoint sorted the term values of the managed properties. These are in order to SharePoint but are not results that users want.

Figure 3: Managed properties term values

In figure 3 I highlighted in red the term ID on which SharePoint performs the sorting of the results. If you check these term ID values, you can see that the results are correctly sorted (that is, 003..., 1147..., 28e1). To solve this problem, you need to configure the managed property to sort on the display value of the term, which requires some extra configuration on your environment.


You solve the problem by using another crawled property that does not contain this term ID related information.

Go to your search schema page and click the Crawled Properties link. On the Crawled Properties page (figure 4), search for the crawled properties linked to your managed metadata column.

The Crawled Properties show the property with the _taxid_ is currently mapped.

Figure 4: Crawled properties

You should get two crawled property results: a crawled property with and without a taxId in its name. The one without the taxId only contains the term's display value. This crawled property will not yet be mapped to a managed metadata column.

Click the Managed Properties link and search for RefinableString (figure 5). Click on one of the RefinableString properties that is not yet in use, and map this managed property with the ows_TestTerm (ows_ColumnName) crawled property.

Search for an unused RefinableString managed property and map that.

Figure 5: RefinableString - map the Managed Crawled Property to ows_TestTerm

Wait for a full crawl, or if you are working on-premises you could start one. Once the crawl is complete you can configure the new managed property on the sorting tab in the query builder. Now the results should be in the correct visual order (figure 6):

Here are the results you want, correctly sorted, using managed metadata.

Figure 6: Correctly sorted results

As figure 6 shows, the results are sorted based on the display value of the managed property term instead of the term ID.

You can find Elio's original blog post here.

Topic: Search

Sign in with

Or register

  • This is an excellent post. I am trying to sort results by OOTB Managed property called Title but it was not sorting correctly. I followed you article and mapped OWS_TITLE crawled property to RefinableString00. After the crawling is completed I still see the same result meaning the result is not sorted. My query looks something like below:

    Am I doing something wrong here?
  • This is a great post. I am trying to do something similar with the content search web part. I am trying to sort on the team site name(title), but coming up with a mix bag of results. The managed properties that I have mapped do not appear to altering the sort at all. Do you have any recommendations?