Click here to close now.



Welcome!

Apache Authors: William Schmarzo, Christopher Harrold, Elizabeth White, Talend Inc., Adrian Bridgwater

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
Basho Technologies has announced the latest release of Basho Riak TS, version 1.3. Riak TS is an enterprise-grade NoSQL database optimized for Internet of Things (IoT). The open source version enables developers to download the software for free and use it in production as well as make contributions to the code and develop applications around Riak TS. Enhancements to Riak TS make it quick, easy and cost-effective to spin up an instance to test new ideas and build IoT applications. In addition to...
When people aren’t talking about VMs and containers, they’re talking about serverless architecture. Serverless is about no maintenance. It means you are not worried about low-level infrastructural and operational details. An event-driven serverless platform is a great use case for IoT. In his session at @ThingsExpo, Animesh Singh, an STSM and Lead for IBM Cloud Platform and Infrastructure, will detail how to build a distributed serverless, polyglot, microservices framework using open source tec...
Apixio Inc. has raised $19.3 million in Series D venture capital funding led by SSM Partners with participation from First Analysis, Bain Capital Ventures and Apixio’s largest angel investor. Apixio will dedicate the proceeds toward advancing and scaling products powered by its cognitive computing platform, further enabling insights for optimal patient care. The Series D funding comes as Apixio experiences strong momentum and increasing demand for its HCC Profiler solution, which mines unstruc...
IoT offers a value of almost $4 trillion to the manufacturing industry through platforms that can improve margins, optimize operations & drive high performance work teams. By using IoT technologies as a foundation, manufacturing customers are integrating worker safety with manufacturing systems, driving deep collaboration and utilizing analytics to exponentially increased per-unit margins. However, as Benoit Lheureux, the VP for Research at Gartner points out, “IoT project implementers often ...
It is one thing to build single industrial IoT applications, but what will it take to build the Smart Cities and truly society changing applications of the future? The technology won’t be the problem, it will be the number of parties that need to work together and be aligned in their motivation to succeed. In his Day 2 Keynote at @ThingsExpo, Henrik Kenani Dahlgren, Portfolio Marketing Manager at Ericsson, discussed how to plan to cooperate, partner, and form lasting all-star teams to change t...
In his general session at 18th Cloud Expo, Lee Atchison, Principal Cloud Architect and Advocate at New Relic, discussed cloud as a ‘better data center’ and how it adds new capacity (faster) and improves application availability (redundancy). The cloud is a ‘Dynamic Tool for Dynamic Apps’ and resource allocation is an integral part of your application architecture, so use only the resources you need and allocate /de-allocate resources on the fly.
In his keynote at 18th Cloud Expo, Andrew Keys, Co-Founder of ConsenSys Enterprise, provided an overview of the evolution of the Internet and the Database and the future of their combination – the Blockchain. Andrew Keys is Co-Founder of ConsenSys Enterprise. He comes to ConsenSys Enterprise with capital markets, technology and entrepreneurial experience. Previously, he worked for UBS investment bank in equities analysis. Later, he was responsible for the creation and distribution of life sett...
Presidio has received the 2015 EMC Partner Services Quality Award from EMC Corporation for achieving outstanding service excellence and customer satisfaction as measured by the EMC Partner Services Quality (PSQ) program. Presidio was also honored as the 2015 EMC Americas Marketing Excellence Partner of the Year and 2015 Mid-Market East Partner of the Year. The EMC PSQ program is a project-specific survey program designed for partners with Service Partner designations to solicit customer feedbac...
Machine Learning helps make complex systems more efficient. By applying advanced Machine Learning techniques such as Cognitive Fingerprinting, wind project operators can utilize these tools to learn from collected data, detect regular patterns, and optimize their own operations. In his session at 18th Cloud Expo, Stuart Gillen, Director of Business Development at SparkCognition, discussed how research has demonstrated the value of Machine Learning in delivering next generation analytics to imp...
There are several IoTs: the Industrial Internet, Consumer Wearables, Wearables and Healthcare, Supply Chains, and the movement toward Smart Grids, Cities, Regions, and Nations. There are competing communications standards every step of the way, a bewildering array of sensors and devices, and an entire world of competing data analytics platforms. To some this appears to be chaos. In this power panel at @ThingsExpo, moderated by Conference Chair Roger Strukhoff, Bradley Holt, Developer Advocate a...
Connected devices and the industrial internet are growing exponentially every year with Cisco expecting 50 billion devices to be in operation by 2020. In this period of growth, location-based insights are becoming invaluable to many businesses as they adopt new connected technologies. Knowing when and where these devices connect from is critical for a number of scenarios in supply chain management, disaster management, emergency response, M2M, location marketing and more. In his session at @Th...
The cloud market growth today is largely in public clouds. While there is a lot of spend in IT departments in virtualization, these aren’t yet translating into a true “cloud” experience within the enterprise. What is stopping the growth of the “private cloud” market? In his general session at 18th Cloud Expo, Nara Rajagopalan, CEO of Accelerite, explored the challenges in deploying, managing, and getting adoption for a private cloud within an enterprise. What are the key differences between wh...
A strange thing is happening along the way to the Internet of Things, namely far too many devices to work with and manage. It has become clear that we'll need much higher efficiency user experiences that can allow us to more easily and scalably work with the thousands of devices that will soon be in each of our lives. Enter the conversational interface revolution, combining bots we can literally talk with, gesture to, and even direct with our thoughts, with embedded artificial intelligence, wh...
Cloud computing is being adopted in one form or another by 94% of enterprises today. Tens of billions of new devices are being connected to The Internet of Things. And Big Data is driving this bus. An exponential increase is expected in the amount of information being processed, managed, analyzed, and acted upon by enterprise IT. This amazing is not part of some distant future - it is happening today. One report shows a 650% increase in enterprise data by 2020. Other estimates are even higher....
SYS-CON Events announced today that Bsquare has been named “Silver Sponsor” of SYS-CON's @ThingsExpo, which will take place on November 1–3, 2016, at the Santa Clara Convention Center in Santa Clara, CA. For more than two decades, Bsquare has helped its customers extract business value from a broad array of physical assets by making them intelligent, connecting them, and using the data they generate to optimize business processes.
Internet of @ThingsExpo, taking place November 1-3, 2016, at the Santa Clara Convention Center in Santa Clara, CA, is co-located with 19th 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 and enterprise IT since the creation of the Worldwide Web more than 20 years ago. All major researchers estimate there will be tens of billions devices - comp...
19th Cloud Expo, taking place November 1-3, 2016, 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 enterpri...
The 19th International Cloud Expo has announced that its Call for Papers is open. Cloud Expo, to be held November 1-3, 2016, at the Santa Clara Convention Center in Santa Clara, CA, brings together Cloud Computing, Big Data, Internet of Things, DevOps, Digital Transformation, Microservices 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 opportuni...
Internet of @ThingsExpo, taking place November 1-3, 2016, at the Santa Clara Convention Center in Santa Clara, CA, is co-located with the 19th International Cloud Expo and will feature technical sessions from a rock star conference faculty and the leading industry players in the world and ThingsExpo Silicon Valley Call for Papers is now open.
There is little doubt that Big Data solutions will have an increasing role in the Enterprise IT mainstream over time. Big Data at Cloud Expo - to be held November 1-3, 2016, at the Santa Clara Convention Center in Santa Clara, CA - has announced its Call for Papers is open. Cloud computing is being adopted in one form or another by 94% of enterprises today. Tens of billions of new devices are being connected to The Internet of Things. And Big Data is driving this bus. An exponential increase is...