Summary: In this article for SharePoint administrators, 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, as demonstrated in this TechNet article: 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.
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
Figure 1: Use Other Labels in managed metadata to add synonyms, for example, writing out “and” for common searches that might contain an ampersand.
- 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 article.
The long version
There are two concepts to understand here:
For the rest of this article, 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.
Figure 2: A simple Contoso search for the word television without search operators.
Then I searched for “TV” and SharePoint returned 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.
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 two documents returned in search results that contain both “Television” and “TV”).
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!
- Go to Manage query rules.
Figure 6: In SharePoint Admin Center, choose Manage Query Rules.
- Select a Source* from the drop-down menu and then click New Query Rule.
Figure 7: Choose the context for the query rule 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.
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.
Figure 9: SharePoint uses the query rule, which contains the search operator, and we get the 19 results we expected.
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.
You can read Kim’s original post here: http://kimfrehe.com/search-for-synonyms-in-office-365-sharepoint-online/