Share via


Create and import a thesaurus in SharePoint Server 2013

 

In this blog post:

NOTE: Thesaurus is not available in SharePoint Online.

 

Why synonyms matter when you search
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, you might enter “flower image,” whereas I 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 you search for information, this can be a challenge. For example, if you want to see the Monthly Sales Report, you’ll most likely search for it by using the terms Monthly Sales Report. However, the people that create this report might use the acronym MSR. So, when you search for Monthly Sales Report, no search results are returned. 

How people search for documents

 

In SharePoint Server 2013 you can easily create and upload a thesaurus that contains synonyms for search phrases and acronyms. In this blog post, I’ll use a simple example to show you how you can do this.

Imagine that you have two documents in a library:

  • A Word document titled “Coffee.”
  • A PowerPoint document titled “Cup of Joe.”

Two documents in a library

 

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

 

Search result for coffee

 

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

 

Search result for cup of joe

 

For both documents to be returned when you search for either coffee or cup of joe, you can create a thesaurus. Here’s how you do that:

 

 

How to create a thesaurus

  1. Open a text editor, for example Notepad.
  2. In the text editor, enter the columns of your thesaurus: Key, Synonym, Language
  3. Use commas to separate the words.

Line 1 in thesaurus 

  1. 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 in thesaurus

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

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

Line 3 in thesaurus

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

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

Save thesaurus as .csv with UTF-8 encoding

 

Now that you have created your thesaurus, the next step is to import it to SharePoint Server 2013. Here’s how you do this:

 

 

How to import a thesaurus
NOTE: To import a thesaurus, you have to be a Search service application administrator

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

SharePoint 2013 Management Shell

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

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

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

Run script to import thesaurus

 

That's it!

 

IMPORTANT: When you import a thesaurus, the existing thesaurus will be overwritten. If you want to add new phrases to your thesaurus, you should add them to the thesaurus file you’ve already imported. You can’t export a thesaurus file, so you should maintain your thesaurus file in an external system, for example on a file share. 

 

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

 

Two results returned for coffee

 

Two results returned for cup of joe

 

 

Additional information
Create and deploy a thesaurus in SharePoint Server 2013

Coffee_thesaurus.csv

Comments

  • Anonymous
    January 01, 2003
    Thx for the post. But what is not completely clear to me is when specifyingaka,also known asDo you have to specify it as folowsaka,"also known as"to be able to mean that is is the sentence that you are looking for. Or is this the default?adTHANKSvance,Jan

  • Anonymous
    January 01, 2003
    Hi Michael,

    No, the thesaurus is not available in SharePoint Online.

    Bella

  • Anonymous
    January 01, 2003
    Hi Ambily,

    Thesaurus is not available in SharePoint Online.

    Bella

  • Anonymous
    January 01, 2003
    Hi Jan, In your case, I would specify the following: Key, Synonym,Language
    aka,also known as,en
    also known as,aka,en Hope this helps,
    Bella

  • Anonymous
    January 01, 2003
    Hi gopal,

    Can you give some more information about your problem? Are you getting any error messages?

    Bella

  • Anonymous
    January 01, 2003
    Hi Aravind,

    You can't export a thesaurus file, so you should maintain your thesaurus file in an external system. If you want to remove a term, delete the term from you thesaurus file, and then import the file. When you import, the existing thesaurus will be overwritten.

    Hope this helps,
    Bella

  • Anonymous
    January 01, 2003
    Hi Polo,

    You can use the following syntax: \

    Hope this helps,
    Bella

  • Anonymous
    January 01, 2003
    Hi TerjeAT, Yes, you are correct. The thesaurus is not applied to people search. Bella

  • Anonymous
    January 01, 2003
    Hi Abduallah,

    For the thesaurus to work, you have to import the external file into SharePoint Server 2013.

    Bella

  • Anonymous
    January 01, 2003
    The comment has been removed

  • Anonymous
    January 01, 2003
    Hi Manasi,

    Yes, that should work. But make sure that you also use UTF-8 encoding.

    Bella

  • Anonymous
    January 01, 2003
    Hi Roland,

    I'm not quite sure I understand your questions, but you can't add managed properties to a thesaurus file.

    Bella

  • Anonymous
    December 04, 2013
    Does a full crawl have to run for the new thesaurus to become effective?

  • Anonymous
    December 05, 2013
    Hi Kerstin, No, you don’t have to do a crawl after you've uploaded your thesaurus.   As I don’t know your environment, it’s difficult to say how long it’ll take until you see the effects, but you should see the effects of the thesaurus relative soon. Bella    

  • Anonymous
    December 11, 2013
    Thanks for this post. Noticed a mistake: "so you should maintain your thesaurus file in an external system, for example on a file share." Err..we are talking SharePoint here right ;-)

  • Anonymous
    December 12, 2013
    Hi Carry, Sorry for not being clear. The point that I wanted to get across was that since you can’t export the existing thesaurus file, you should make sure to maintain the file somewhere. You can of course store your thesaurus file in a SharePoint library. Bella

  • Anonymous
    January 30, 2014
    How to revert or remove an item? Is it possible? Creating a new file with the entry removed and exporting will fix the problem (reverting back)?

  • Anonymous
    February 13, 2014
    The Thesaurus does not work on the People Scope.. am I correct? In my case they work perfectly in normal search, but as I switch to people search the synonyms does not apply anymore...

  • Anonymous
    April 24, 2014
    Hi Bella, I am unable to import therausus file. Please help

  • Anonymous
    April 26, 2014
    Hi Bella, I followed the steps as mentioned above, but the import fails. Please help

  • Anonymous
    May 19, 2014
    The comment has been removed

  • Anonymous
    August 14, 2014
    Hi,
    can you explain how can we get the UNC path of the thesaurus file?

  • Anonymous
    August 26, 2014
    Bella,

    Is there a supported way to add Synonyms on SharePoint Online?

    Thanks.

  • Anonymous
    January 20, 2015
    dears , I have custom need to use external DB as dictionary for SharePoint Search ,

    are this applicable?

    Thanks,

  • Anonymous
    April 15, 2015
    The comment has been removed

  • Anonymous
    April 16, 2015
    Hi Bella, if we create the list in an excel file and save it as .csv format, will that work?