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
- If you’re using managed metadata, you can use an “Other Labels” field to add synonyms for each term in a Managed Term Set: Specify synonyms for a (managed) term
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:
- search operators, which I will expand on in a later post, but here is a link to a resource for your viewing pleasure: Using Operators in Keyword Query – MSDN
- query rules, which I will expand on in a later post, but here is a link to a resource for your viewing pleasure: Manage Query Rules in SharePoint – TechNet
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.
Then I searched for “TV” and SharePoint returned 17 results.
Then I entered a search with the “WORDS” search operator in lowercase letters and SharePoint returned 1 result.
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”).
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!
- Go to Manage query rules.
- Select a Source from the drop-down menu and then click New Query Rule.
- Enter a Rule Name. For this example, we’ll call it Television.
- In the Query Conditions section, choose Query Matches Keyword Exactly from the drop-down menu.
- Enter each term that you want to be included as a synonym (my example shows the words “Television” and “TV”) separated by semi-colons.
- In the Actions section choose Change ranked results by the changing the query and add WORDS(Television, TV) and save the rule.
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.
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.