Click here to close now.

Welcome!

Apache Authors: Elizabeth White, Yeshim Deniz, Pat Romanski, Carmen Gonzalez, Liz McMillan

Blog Feed Post

How to: Get related terms for a SharePoint 2013 Hashtag

If you have been following my posts lately, you might have noticed I have been dissecting the inner workings of the Hashtag Profile page (HashTagProfile.aspx).  I started with using search to query hashtag data and then yesterday I posted on how to query for trending tags.  The last component of this page is how to get the related terms of the hashtag.  As a reminder of what this does, it allows you to associate terms in the term store with a hashtag.  Whenever that term is used, it gets associated with the hashtag.  You can see the related tags in the screenshot below.

RelatedTagsProfilePage

Figuring this out took a bit of digging.  Remember that hashtags are nothing but terms themselves.  Ultimately what I discovered is that each term in the term store has the ability to add associations.  Unfortunately, the method to access these associations is marked internal meaning we can’t access it.  Luckily, I found that this really just gets stored in a custom property of the term.  Let’s take a look at what you need to do.

For simplicity, I used the server-side object model using a console application.  It should be possible to do this with JavaScript too though.  I suspect you can access the same information using SP.Taxonomy.Term.localCustomProperties.

Start by adding references for the following:

  • Microsoft.SharePoint.dll
  • Microsoft.SharePoint.Taxonomy.dll

In our class itself, we’ll need the following namespaces.

using Microsoft.SharePoint;

using Microsoft.SharePoint.Taxonomy;

I am going to get access to the term store in my case using an SPSite object for any given site collection on the site.

using (SPSite siteCollection = new SPSite("http://server/sitecollection"))

Inside, the using block, I get a TaxonomySession and TermStore object.

TaxonomySession taxonomySession = new TaxonomySession(siteCollection);

TermStore termStore = taxonomySession.DefaultKeywordsTermStore;

Now we need to get access to the term in the hashtag.  You can get this in a variety of ways but I am simply going to use the GUID which I took from the URL of the HashTagProfile.aspx page. Otherwise, you can access a Group object first and then find the term you are looking for that way.

RelatedTagsProfilePageUrl

Term

term = termStore.GetTerm(new Guid("cb9308fe-a187-4a3d-9e6a-657b06906f89")); To access the associated terms, we need to look in the CustomProperties collection with a value of _Sys_HashAssoc

string associatedTerms;

term.CustomProperties.TryGetValue("_Sys_HashAssoc", out associatedTerms);

This gives us a delimited string with the GUID of each associated term and the owner.  Here is what it looks like.

"973bdb1b-eb9f-4f8b-8512-6440b0913b4f||0#.w|sharepoint\\sp_setup||4c1ad4aa-77f6-40de-bd16-210cad44d0b3||0#.w|sharepoint\\sp_setup"

The delimiter to use is “||”.  Using string.Split() we can get the GUIDs we need and then look up the names of the terms.

string[] termGuidArray = associatedTerms.Split(new string[1] {"||"}, StringSplitOptions.None);

We are only interested in the terms, so we will loop through them with an increment of 2.

for (int i = 0; i < termGuidArray.Length; i += 2)

{

    Term associatedTerm = termStore.GetTerm(new Guid(termGuidArray[i]));

    Console.WriteLine("{0} ({1})", associatedTerm.Name, termGuidArray[i]);

}

Here we just use the GetTerm() method using the GUID we have parsed to print out the name of the term.

When the code executes, it looks like this.

RelatedTagsConsoleApplication

Here is what the entire code snippet looks like together.

using System;

using System.Collections.Generic;

using System.Linq;

using System.Text;

using System.Threading.Tasks;

 

using Microsoft.SharePoint;

using Microsoft.SharePoint.Taxonomy;

 

namespace TaxonomyConsoleApplication

{

    class Program

    {

        static void Main(string[] args)

        {

            using (SPSite siteCollection = new SPSite("http://sp2010/sites/test"))

            {

                TaxonomySession taxonomySession = new TaxonomySession(siteCollection);

                TermStore termStore = taxonomySession.DefaultKeywordsTermStore;

                Term term = termStore.GetTerm(new Guid("cb9308fe-a187-4a3d-9e6a-657b06906f89"));

                string associatedTerms;

                term.CustomProperties.TryGetValue("_Sys_HashAssoc", out associatedTerms);

 

                string[] termGuidArray = associatedTerms.Split(new string[1] {"||"}, StringSplitOptions.None);

 

                for (int i = 0; i < termGuidArray.Length; i += 2)

                {

                    Term associatedTerm = termStore.GetTerm(new Guid(termGuidArray[i]));

                    Console.WriteLine("{0} ({1})", associatedTerm.Name, termGuidArray[i]);

                }

            }

 

            Console.ReadLine();

        }

    }

}

If you have been wanting to customize this functionality, I hope that you find today’s example useful.

Read the original blog entry...

More Stories By Corey Roth

Corey Roth, a SharePoint Server MVP, is a consultant at Hitachi Consulting specializing in SharePoint and Office 365 for clients in the energy sector. He has more than ten years of experience delivering solutions in the energy, travel, advertising and consumer electronics verticals.

Corey specializes in delivering ECM and search solutions to clients using SharePoint. Corey has always focused on rapid adoption of new Microsoft technologies including Visual Studio 2013, Office 365, and SharePoint.

He is a member of the .NET Mafia (www.dotnetmafia.com) where he blogs about the latest technology and SharePoint. He is dedicated to the community and speaks regularly at user groups and SharePoint Saturdays.

@ThingsExpo Stories
The 4th International Internet of @ThingsExpo, co-located with the 17th International Cloud Expo - to be held November 3-5, 2015, at the Santa Clara Convention Center in Santa Clara, CA - announces that its Call for Papers is open. The Internet of Things (IoT) is the biggest idea since the creation of the Worldwide Web more than 20 years ago.
"People are a lot more knowledgeable about APIs now. There are two types of people who work with APIs - IT people who want to use APIs for something internal and the product managers who want to do something outside APIs for people to connect to them," explained Roberto Medrano, Executive Vice President at SOA Software, in this SYS-CON.tv interview at Cloud Expo, held Nov 4–6, 2014, at the Santa Clara Convention Center in Santa Clara, CA.
The 17th International Cloud Expo has announced that its Call for Papers is open. 17th International Cloud Expo, to be held November 3-5, 2015, at the Santa Clara Convention Center in Santa Clara, CA, brings together Cloud Computing, APM, APIs, Microservices, Security, Big Data, Internet of Things, DevOps and WebRTC to one location. With cloud computing driving a higher percentage of enterprise IT budgets every year, it becomes increasingly important to plant your flag in this fast-expanding business opportunity. Submit your speaking proposal today!
In their session at @ThingsExpo, Shyam Varan Nath, Principal Architect at GE, and Ibrahim Gokcen, who leads GE's advanced IoT analytics, focused on the Internet of Things / Industrial Internet and how to make it operational for business end-users. Learn about the challenges posed by machine and sensor data and how to marry it with enterprise data. They also discussed the tips and tricks to provide the Industrial Internet as an end-user consumable service using Big Data Analytics and Industrial Cloud.
Sensor-enabled things are becoming more commonplace, precursors to a larger and more complex framework that most consider the ultimate promise of the IoT: things connecting, interacting, sharing, storing, and over time perhaps learning and predicting based on habits, behaviors, location, preferences, purchases and more. In his session at @ThingsExpo, Tom Wesselman, Director of Communications Ecosystem Architecture at Plantronics, will examine the still nascent IoT as it is coalescing, including what it is today, what it might ultimately be, the role of wearable tech, and technology gaps stil...
The explosion of connected devices / sensors is creating an ever-expanding set of new and valuable data. In parallel the emerging capability of Big Data technologies to store, access, analyze, and react to this data is producing changes in business models under the umbrella of the Internet of Things (IoT). In particular within the Insurance industry, IoT appears positioned to enable deep changes by altering relationships between insurers, distributors, and the insured. In his session at @ThingsExpo, Michael Sick, a Senior Manager and Big Data Architect within Ernst and Young's Financial Servi...
17th Cloud Expo, taking place Nov 3-5, 2015, at the Santa Clara Convention Center in Santa Clara, CA, will feature technical sessions from a rock star conference faculty and the leading industry players in the world. Cloud computing is now being embraced by a majority of enterprises of all sizes. Yesterday's debate about public vs. private has transformed into the reality of hybrid cloud: a recent survey shows that 74% of enterprises have a hybrid cloud strategy. Meanwhile, 94% of enterprises are using some form of XaaS – software, platform, and infrastructure as a service.
The Workspace-as-a-Service (WaaS) market will grow to $6.4B by 2018. In his session at 16th Cloud Expo, Seth Bostock, CEO of IndependenceIT, will begin by walking the audience through the evolution of Workspace as-a-Service, where it is now vs. where it going. To look beyond the desktop we must understand exactly what WaaS is, who the users are, and where it is going in the future. IT departments, ISVs and service providers must look to workflow and automation capabilities to adapt to growing demand and the rapidly changing workspace model.
Since 2008 and for the first time in history, more than half of humans live in urban areas, urging cities to become “smart.” Today, cities can leverage the wide availability of smartphones combined with new technologies such as Beacons or NFC to connect their urban furniture and environment to create citizen-first services that improve transportation, way-finding and information delivery. In her session at @ThingsExpo, Laetitia Gazel-Anthoine, CEO of Connecthings, will focus on successful use cases.
One of the biggest impacts of the Internet of Things is and will continue to be on data; specifically data volume, management and usage. Companies are scrambling to adapt to this new and unpredictable data reality with legacy infrastructure that cannot handle the speed and volume of data. In his session at @ThingsExpo, Don DeLoach, CEO and president of Infobright, will discuss how companies need to rethink their data infrastructure to participate in the IoT, including: Data storage: Understanding the kinds of data: structured, unstructured, big/small? Analytics: What kinds and how responsiv...
Building low-cost wearable devices can enhance the quality of our lives. In his session at Internet of @ThingsExpo, Sai Yamanoor, Embedded Software Engineer at Altschool, provided an example of putting together a small keychain within a $50 budget that educates the user about the air quality in their surroundings. He also provided examples such as building a wearable device that provides transit or recreational information. He then reviewed the resources available to build wearable devices at home including open source hardware, the raw materials required and the options available to power s...
With major technology companies and startups seriously embracing IoT strategies, now is the perfect time to attend @ThingsExpo in Silicon Valley. Learn what is going on, contribute to the discussions, and ensure that your enterprise is as "IoT-Ready" as it can be! Internet of @ThingsExpo, taking place Nov 3-5, 2015, at the Santa Clara Convention Center in Santa Clara, CA, is co-located with 17th Cloud Expo and will feature technical sessions from a rock star conference faculty and the leading industry players in the world. The Internet of Things (IoT) is the most profound change in personal an...
DevOps tends to focus on the relationship between Dev and Ops, putting an emphasis on the ops and application infrastructure. But that’s changing with microservices architectures. In her session at DevOps Summit, Lori MacVittie, Evangelist for F5 Networks, will focus on how microservices are changing the underlying architectures needed to scale, secure and deliver applications based on highly distributed (micro) services and why that means an expansion into “the network” for DevOps.
How do APIs and IoT relate? The answer is not as simple as merely adding an API on top of a dumb device, but rather about understanding the architectural patterns for implementing an IoT fabric. There are typically two or three trends: Exposing the device to a management framework Exposing that management framework to a business centric logic Exposing that business layer and data to end users. This last trend is the IoT stack, which involves a new shift in the separation of what stuff happens, where data lives and where the interface lies. For instance, it's a mix of architectural styles ...
The 3rd International @ThingsExpo, co-located with the 16th International Cloud Expo – to be held June 9-11, 2015, at the Javits Center in New York City, NY – is now accepting Hackathon proposals. Hackathon sponsorship benefits include general brand exposure and increasing engagement with the developer ecosystem. At Cloud Expo 2014 Silicon Valley, IBM held the Bluemix Developer Playground on November 5 and ElasticBox held the DevOps Hackathon on November 6. Both events took place on the expo floor. The Bluemix Developer Playground, for developers of all levels, highlighted the ease of use of...
We’re no longer looking to the future for the IoT wave. It’s no longer a distant dream but a reality that has arrived. It’s now time to make sure the industry is in alignment to meet the IoT growing pains – cooperate and collaborate as well as innovate. In his session at @ThingsExpo, Jim Hunter, Chief Scientist & Technology Evangelist at Greenwave Systems, will examine the key ingredients to IoT success and identify solutions to challenges the industry is facing. The deep industry expertise behind this presentation will provide attendees with a leading edge view of rapidly emerging IoT oppor...
Connected devices and the Internet of Things are getting significant momentum in 2014. In his session at Internet of @ThingsExpo, Jim Hunter, Chief Scientist & Technology Evangelist at Greenwave Systems, examined three key elements that together will drive mass adoption of the IoT before the end of 2015. The first element is the recent advent of robust open source protocols (like AllJoyn and WebRTC) that facilitate M2M communication. The second is broad availability of flexible, cost-effective storage designed to handle the massive surge in back-end data in a world where timely analytics is e...
We certainly live in interesting technological times. And no more interesting than the current competing IoT standards for connectivity. Various standards bodies, approaches, and ecosystems are vying for mindshare and positioning for a competitive edge. It is clear that when the dust settles, we will have new protocols, evolved protocols, that will change the way we interact with devices and infrastructure. We will also have evolved web protocols, like HTTP/2, that will be changing the very core of our infrastructures. At the same time, we have old approaches made new again like micro-services...
SYS-CON Events announced today that Gridstore™, the leader in hyper-converged infrastructure purpose-built to optimize Microsoft workloads, will exhibit at SYS-CON's 16th International Cloud Expo®, which will take place on June 9-11, 2015, at the Javits Center in New York City, NY. Gridstore™ is the leader in hyper-converged infrastructure purpose-built for Microsoft workloads and designed to accelerate applications in virtualized environments. Gridstore’s hyper-converged infrastructure is the industry’s first all flash version of HyperConverged Appliances that include both compute and storag...
For years, we’ve relied too heavily on individual network functions or simplistic cloud controllers. However, they are no longer enough for today’s modern cloud data center. Businesses need a comprehensive platform architecture in order to deliver a complete networking suite for IoT environment based on OpenStack. In his session at @ThingsExpo, Dhiraj Sehgal from PLUMgrid will discuss what a holistic networking solution should really entail, and how to build a complete platform that is scalable, secure, agile and automated.