Thursday, September 13, 2012

Simple Concept: How to search by managed metadata field or term?

[Question]: I have created a term and used it in managed metadata column. How can I search by term value to find any place where such term has been used?

For an example,
I have a managed metadata column "Project Tags" in the library.
I have an item in the library with value "eReview" in the Project Tags column.
I want to be able to search by eReview to find that item

Once you have created a managed metadata column, you have to run a crawl.
Crawl will automatically  create a crawled property and managed property that look at the managed metadata column.

What you have to do is to check "Include values for this property in the search index". It will give ability to search by term title in the search.

In case you need to search byTerm id, use  a managed property value like this:

Where owsTaxIdProject is a managed property and term id - the actual term of id (in this case -  eReview).

You may ask 2 questions at this time:
1 . Why I need to search by Term id?
 - You may want to build a custom webpart to show all related content based on the select term.
2.  How do I know Term id?
One way to find a term id  is to go to the site collection hidden list Lists/TaxonomyHiddenList
Other popular option is to use seach refiner with the term that is interesting for you:
Select the value in the refiner and then look at the url of the search page:

Easy way to decode this - URL Decoder/Encoder

If you have several metadata columns in the several lists that look at the the same term set, but you call them differently (internal names in the different lists are not the same), the crawler will create several managed properties.
You want them unite. Find all crawled properties that have been created based on your managed metadata.

Hint: name of crawled property has a pattern. ows prefix means - custom metadata, taxId - refers to the type of column- Managed metadata. Hence you can find your all crawled managed metadata columns by searching withing crawled properties by name taxId.

And then map the crawled properties to the one Managed property.

Good luck with Taxonomy!