How to: Use search to query social tag (hashtag) data
Posted
Tuesday, November 5, 2013 4:50 PM
by
CoreyRoth
I’ve been digging deeper into the SharePoint 2013 social API a bit more lately and I was particularly interested in social tags (hashtags). In particular I wanted to find a way to see what social feed items have been tagged to a given hashtag similar to what we see on the page HashTagProfile.aspx on your personal site.
This particular page does a number of things. It shows all social feed items associated with the hashtag. It also allows a tag administrator to associate this tag with an item in the term store. This allows any document tagged to that particular item to be associated with the hashtag. The SEE ALL link got me interested because I noticed it was a search query.
Here’s an example of what the query looks like.
NOT(ContentTypeId:0x01FD4FB0210AB50249908EAA47E6BD3CFE8B* OR ContentTypeId:0x01FD59A0DF25F1E14AB882D2C87D4874CF84* OR ContentTypeId:0x012002* OR ContentTypeId:0x0107* OR WebTemplate=COMMUNITY)owstaxIdMetadataAllTagsInfo:#03d247305-a0aa-46cc-8842-1806debbe1ae OR owstaxidmetadataalltagsinfo:#02890c1bc-0732-41b3-8466-52faf158d406
Breaking that query down, basically it excludes a few content types as well as the community site. The key part of the query I found to be is the owstaxIdMetadataAllTagsInfo managed property. You will notice there are two of them there. It turns out, the first GUID returns all conversations associated with the hashtag. The second GUID returns all documents associated with the Enterprise Keyword. Take a look.
Next the results for the documents associated with the Enterprise Keywords.
If you want to see both together you just combine the query.
This works well, but I really wanted a simpler way to just see the social feed items associated with the hashtag itself. I really didn’t want to have to go and retrieve the GUID for the underlying term first. Luckily, Search is smart and you don’t have to. Just put the human readable term in your query with owstaxIdMetadataAllTagsInfo and it does the rest.
owstaxIdMetadataAllTagsInfo:"#MarketingCampaign"
This actually provides more results than HashTagProfile.aspx does or when querying by GUID. I am not really sure why there is a difference but these results seem to be more complete. Try it out for yourself.