Create and import a thesaurus in SharePoint Server

APPLIES TO: yes-img-132013 yes-img-162016 yes-img-192019 yes-img-seSubscription Edition no-img-sopSharePoint in Microsoft 365

In this article, you'll learn:

People are different. Not only do we look and dress differently, but when we communicate, we use different words to describe the same thing. The same applies to how we search for information. In a search engine, one person might enter "flower image," whereas another might enter "flower picture" or "flower photo." Even though we used different phrases, we were searching for the same information.

And then there are acronyms. Acronyms are especially popular in organizations, but when we search for information, this can be challenging. For example, if we want to see the Monthly Sales Report, we'll most likely search for it by using the terms Monthly Sales Report. But, the people who create this report might use the acronym MSR. So, when we search for Monthly Sales Report, no search results are returned.

Acronyms

In the classic search experience of SharePoint Server, we can easily create and upload a thesaurus that contains synonyms for search phrases and acronyms. In this article, we'll use a simple example to show how to do this.

Suppose you have two documents in a library:

  • A Word document titled "Coffee"

  • A PowerPoint document titled "Cup of Joe"

Two Documents

When you search for coffee, the Word document is returned.

Coffee Result

When you search for cup of joe, the PowerPoint document is returned.

Joe Result

For both documents to be returned when you search for either coffee or cup of joe, we can create a thesaurus.

How to create a thesaurus

  1. Open a text editor, for example Notepad.

  2. In the text editor, enter the columns of our thesaurus: Key, Synonym, and Language.

  3. Use commas to separate the words.

    Line 1

  4. On a new line in the text editor, enter a term or a phrase, a synonym for that term or phrase and a two letter language code. Use commas to separate the phrases, for example Coffee,Cup of Joe,en .

    Line 2

    This means that when users search for "Coffee", search results for both "Coffee" and "Cup of Joe" will be returned.

  5. Repeat step 3, but switch the order of Key and Synonym.

    Line 3

    This means that when users search for "Cup of Joe," search results for both "Cup of Joe" and "Coffee" will be returned.

  6. Save the file as .csv with UTF-8 encoding.

    Save CSV

Now that we've created our thesaurus, the next task is to import it to SharePoint Server.

How to import a thesaurus

Note

To import a thesaurus, you must be a Search service application administrator.

  1. On the server where SharePoint Server is installed, open a SharePoint Management Shell.

    SP Shell

  2. At the command prompt, enter the following command:

$searchApp = Get-SPEnterpriseSearchServiceApplication 
Import-SPEnterpriseSearchThesaurus -SearchApplication $searchApp -Filename <Path>

where <Path> is the UNC path of the thesaurus file.

Run Script

That's it!

Important

When you import a thesaurus, the existing thesaurus will be overwritten. If you want to add new phrases to our thesaurus, you should add them to the thesaurus file we have already imported. You can't export a thesaurus file. Therefore, you should maintain our thesaurus file in an external system, for example on a file share.

To verify that your thesaurus is working the way that you want it to, search for phrases from the thesaurus. In this example scenario, two files were returned for both "coffee" and "cup of joe."

Coffee Expanded

Cup Expanded

See also

Concepts

Create and deploy a thesaurus in SharePoint Server