To programmatically obtain the URL to access the FAST search and return contents filtered by Metadata. To enable a custom search from Taxonomy to find the entire site contents filtered by a selected Term.
The standard SharePoint Fast Search uses the following results page:
When you search content by Key, the results page uses in query string the following:
k= [search key]
If in your site has been configured to leverage the taxonomy and you are using Meta Tags, after a FAST search you will see the new section Tags that contains a the list of the Meta tags found in the searched content.
Now one can refine the search by selecting a tag, such as "SharePoint 2010".
Looking at the top URL for the corresponding the results page, we see:
Within this string:
r indicates the refinement selections.
Further investigation revealed that the owstaxIdMetadataAllTagsInfo is a property used to execute Meta Tags filtering. (http://msdn.microsoft.com/en-us/library/ff625182.aspx)
The string: "AQ9TaGFyZVBvaW50IDIwMTAbAW93c3RheGlkbWV0YWRhdGFhbGx0YWdzaW5mbwAaAl4iIzBmMTI0ODgxNi0yYTllLTQ4ODgtYTQ3MC04NzhjNTQxNDhjNmMiJA%3D%3D"
is in base 64. If one translates it, you will see the following:
SharePoint 2010 is the name of the Term
f1248816-2a9e-4888-a470-878c54148c6c is the Id of the Term
#0 before the term ID means query for only the specified term ID. (MSDN definition)
HOW TO FILTER ALL CONTENTS BY TAG
Suppose one wants to search all the contents and to filter by "SharePoint 2010"' tag.
To realize this one doesn't need to search by 'k' and to refine by 'r', but can directly search by k using the property: owstaxidmetadataalltagsinfo.
This will require the Term Id.
Fortunately this ID can be found programmatically. In this example it is found to be: f1248816-2a9e-4888-a470-878c54148c6c.
Put this together with the page URL and one has:
Now one is able to see all the contents of the site searched by Meta tag.
WHERE CAN ONE USE IT?
If you want to search by Tag and not to refine, this is the solution for you.
For example I want to build a Web Part that show the Taxonomy tree, and for each Term to create a link to the results page that show me all the content that used this tag.
The only problem now is that in the Search Box WP of the results page, you will see 'owstaxIdMetadataAllTagsInfo:0f1248816-2a9e-4888-a470-878c54148c6c'.
One solution is to create a copy of the results page, e.g. TaxonomyResults.aspx and to hide the Search Box WP. If the idea is to search content from the Taxonomy, it means that the Search Box WP is not needed, because in the page will have the taxonomy tree to search by another tag.
CREATE LINK PROGRAMMARICALLY
When you get you Term, you can simply use a method like this to create a link:
private string GetLink(Term t)
string searchUrl = urlSearchResultsPage + "?k=owstaxIdMetadataAllTagsInfo:0" + t.Id.ToString();