December 11, 2015

Search for Synonyms in Office 365 SharePoint Online

Summary: In this article for SharePoint administrators, site owners and content owners, learn to use search operators in combination with query rules so that your search results contain common variations and acronyms of common search terms.

How can you predict what your user will search for? What if they search for an acronym, or the long version of the acronym, or a localized version of a word? Or, what if you work for a global company and there are slightly different variations for different languages?

For example, what will be returned in search results if a user types any of the following?

  • Television, TV, Tellie, televisie (Dutch)
  • Sales & Marketing, Sales and Marketing, Sales, Marketing, SAM
  • EPIC, Event Planner Information Center, Event Planning Tool

Ideally, if a user types any of the terms listed on a single line above, the results should return the same number of results.

I love the fact that you can help users find stuff with synonyms in SharePoint:  Create and deploy a thesaurus in SharePoint Server 2013.   What I DON’T love is that the thesaurus has to be uploaded with PowerShell for on-premises SharePoint, and is not available for SharePoint Online: SharePoint online Search thesaurus for synonyms.

After a little bit of research on operators and how to search…problem solved! In addition, this solution works for both SharePoint Online and SharePoint on-premises, which means that you can emulate a thesaurus without PowerShell or access to Central Admin.

The short version

Print screen of adding a synonym for Managed Metadata

For terms that are not managed terms, you can emulate a thesaurus by creating a query rule that uses the WORDS search operator, i.e. WORDS(word1, word2, word3), which will be the focus of the rest of this post.

The long version

There are two concepts to understand here:

Below, I will walk through an example that shows how to use search operators and then how to use a query rule. I will use the Contoso demo environment (which most SharePoint IT people are familiar with). In figure 2, you can see I searched for “Television” and SharePoint returned 3 results.

Searching for the word "Television" yields 3 results
Figure 2: A simple Contoso search for the word television without search operators.

Then I searched for “TV” and SharePoint returned 17 results.

Searching for the word "TV" yields 17 results
Figure 3: My search of Contoso for TV returned more results.

Then I entered a search with the “WORDS” search operator in lowercase letters and SharePoint returned 1 result.

Use Operator with Words in Wrong Case
Figure 4: Here I did not use the search operator in all caps and I got just one search result. As you’ll see in figure 5, case is important.

Why…didn’t I read the referenced article above that clearly shows search operators should be in all caps? Of course I did; I just wanted to show you the importance of making sure search operators are UPPERCASE. Moving on now….

I then did the same search, but with uppercase operator “WORDS” and SharePoint returned 19 results, (the difference in 17 + 3 is accounted for by 2 documents returned in search results that contain both “Television” and “TV”).

Result of conducting an Operator search with the Correct Case
Figure 5: Same search with an uppercase search operator returns more results.

That’s great, but who wants to be in charge of teaching all your users how to use search operators???

That’s where Query Rules come to the rescue! I simply go to my search settings and create a query rule and voila!

  1. Go to Manage query rules.
Search Setting Create a Query Rule link
Figure 6: In SharePoint Admin Center, choose Manage Query Rules.
  1. Select a Source from the drop-down menu and then click New Query Rule.
Selecting a source and clicking on New Query Rule button
Figure 7: Choose the context for the query rule and then click New Query Rule
  1. Enter a Rule Name. For this example, we’ll call it Television.
  2. In the Query Conditions section, choose Query Matches Keyword Exactly from the drop-down menu.
  3. Enter each term that you want to be included as a synonym (my example shows the words “Television” and “TV”) separated by semi-colons.
  4. In the Actions section choose Change ranked results by the changing the query and add WORDS(Television, TV) and save the rule.
Creating a Query Rule with the WORDS operator
Figure 8: Creating a SharePoint query rule that contains the search operator we used earlier.

Now I will go to my page and search for Television. Remember that the previous result returned 3; but now I get all 19 results that include Television or TV.

Result of Television Search after Query Rule shows correct number of results with TV and Television

You may be asking yourself, “Do I need to create this rule at the Central Admin / Tenant Admin or on the Site Collection? My answer is, “It depends!”

If you want this to apply to all searches in your company, then add it to Central Admin/Tenant Admin. Or, if you only want it to apply to your site, or your Search Center, then add it only on that specific site collection.

*Note on results source from that drop-down menu in step 2. In Office 365, I’m unable to apply a rule to all sources. Microsoft Support says this is by design. I’m investigating this.

5 Comment on “Search for Synonyms in Office 365 SharePoint Online”

  • User
    Scott December 14th, 2015

    Couldn’t Microsoft just build in a Thesaurus? I’m just thinking that it would be a lot of rules to add all of the possible search terms out there.

  • User
    Nicki December 23rd, 2015

    cool article! THX!
    There is also one other option. You can use the option “Query matches dictionary” in you step 4. That offers the option to manage you synonyms in termstore.

  • User
    klfrehe December 24th, 2015

    Thanks Nicki, as always in SharePoint, there are lots of ways to accomplish the same outcome. I appreciate the feedback.

Add Comment

Your email address will not be published.