Create synonyms using a Thesaurus file in SharePoint Server
This is no secret that Search is very important in SharePoint.
Creating a thesaurus file, and uploading it to SharePoint Server, will provide synonyms results to users when they perform a search.
This is not applicable to SharePoint Online (at the time of writing: Dec. 2017).
Let’s get started!
Minimum requirements:
- Search Service Application created
- Search Service Application Admin permissions
Creating the Thesaurus file
A thesaurus file has a very specific format. It contains (in that order) a key, a synonym, and a language.
- Log into your SharePoint Server
- Open Notepad
- Insert the synonyms
Save the thesaurus in your file share as a .csv file and encoding UTF-8 (saved mine on my server called “DCSQL1”)
IMPORTANT:
Save a copy of the thesaurus file also to another location, as there’s no way to export or even retrieve it if it’s lost.
Import the Thesaurus file with PowerShell
- Open SharePoint Management Shell (or PowerShell ISE + add the snappin)
$searchSA = Get-SPEnterpriseSearchServiceApplication
Import-SPEnterpriseSearchThesaurus -SearchApplication $searchSA -FileName <UNC path>
NOTE:
Each time a Thesaurus is uploaded, it will overwrite the current one.
Test the synonyms
Now that everything went well, let’s give it a try.
- Logging into a client machine
- Searching “cbr” should return a document called “Client Budget Report“
- Searching “cso” should return a document called “Client Solution Overview“
If you need more information, please refer to the official documentation.