Thesaurus in SharePoint Server 2013

Thesaurus

In this article we can explore the Thesaurus and its configuration in a SharePoint 2013 Search.

What a Thesaurus is

The words Thesaurus and Synonym mean the same thing.

Thesaurus Synonym
Purpose of a Thesaurus

Users might have difficulty in typing lengthy search texts like:

1. Human Resource

Instead, they can use a pre-configured Thesaurus like:

  1. HR
  2. HRA

How to specify a Thesaurus for SharePoint 2013 to Search

First we need to create a comma-separated Thesaurus CSV file like the following.

Key, Synonym, Language
HR, Human Resources, en
HRA, Human Resources

The language parameter is optional.

How to configure a Thesaurus

We need to use PowerShell scripts to configure a Thesaurus.

Practical

Let us try to configure Thesauruses as an exercise.

Step 1: Initial Empty Search

Try searching for HRA and ensure you are receiving no results.

HRA

This confirms there are no content matching the text HRA.

Step 2: Create Thesaurus file

Create a CSV file with the following content.

Key,Synonym,Language
HR,Human Resources
HRA,Human Resources

Save the file.

Step 3: Install the Thesaurus file

Run the following PowerShell script to install the Thesaurus file.
  1.  # Add PowerShell Snapin  
  2. if ((Get-PSSnapin "Microsoft.SharePoint.PowerShell" -ErrorAction SilentlyContinue) -eq $null)  
  3. {  
  4.     Add-PSSnapin "Microsoft.SharePoint.PowerShell"  
  5. }  
  6.  $searchApp = Get-SPEnterpriseSearchServiceApplication  
  7.  Import-SPEnterpriseSearchThesaurus -SearchApplication $searchApp -Filename "\\server\c$\temp\file.CSV"  

The path should be in UNC format. Please change the server and file names appropriately.

If the installation succeeded, you will get the following message.

installation succeeded

Step 4: Test the Search

Back in SharePoint, repeat the search using the text HRA. You should receive the following results.
 
Test the Search

This confirms the successful configuration of the Thesaurus. Please note that the results are immediate.
 
Note

Please note that I have configured the content sources to jeanpaulva This makes the content text Human Resources available.

References

Create and deploy a thesaurus in SharePoint Server 2013

Summary

In this article we explored Thesauruses configuration. The PowerShell script is attached with the article.