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
 
 

Coffee_thesaurus.csv

Comments (26)

  1. Anonymous says:

    Thx for the post. But what is not completely clear to me is when specifying
    aka,also known as
    Do you have to specify it as folows
    aka,"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

  2. Bella_Engen says:

    Hi Michael,

    No, the thesaurus is not available in SharePoint Online.

    Bella

  3. Bella_Engen says:

    Hi Ambily,

    Thesaurus is not available in SharePoint Online.

    Bella

  4. Bella_Engen says:

    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

  5. Bella_Engen says:

    Hi gopal,

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

    Bella

  6. Bella_Engen says:

    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

  7. Bella_Engen says:

    Hi Polo,

    You can use the following syntax: \\

    Hope this helps,
    Bella

  8. Bella_Engen says:

    Hi TerjeAT,

    Yes, you are correct. The thesaurus is not applied to people search.

    Bella

  9. Anonymous says:

    Hi Abduallah,

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

    Bella

  10. Anonymous says:

    Hi Harry,

    No, you can’t import several synonyms in one line. You have to use the syntax Key, Synonym, Language.

    Bella

  11. Anonymous says:

    Hi Manasi,

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

    Bella

  12. Anonymous says:

    Hi Roland,

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

    Bella

  13. Kerstin N says:

    Does a full crawl have to run for the new thesaurus to become effective?

  14. Bella_Engen says:

    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    

  15. Carry Megens says:

    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 😉

  16. Bella_Engen says:

    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

  17. 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)?

  18. TerjeAT says:

    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…

  19. gopal nayak says:

    Hi Bella, I am unable to import therausus file. Please help

  20. gopal nayak says:

    Hi Bella, I followed the steps as mentioned above, but the import fails. Please help

  21. Ambily says:

    How to Do it on Sharepoint 2013 – office 365 Online Environment? we don't have access to execute the Powershell script but wanted to Create Synonyms.

  22. Polo says:

    Hi,
    can you explain how can we get the UNC path of the thesaurus file?

  23. ML49448 says:

    Bella,

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

    Thanks.

  24. Abduallah says:

    dears , I have custom need to use external DB as dictionary for SharePoint Search ,

    are this applicable?

    Thanks,

  25. Harry says:

    Hi Bella,

    I have a huge grid of synonyms with app. 10 columns!
    There must be a way of importing more that just a pair of synonyms at one line!?

    Example:

    Key,Synonym,Synonym,Synonym,Synonym,Language
    Coffee,Espresso,Macchiatto,Latte,Cappuccino,en

    ????

    A number of column combinations I would have to Import would be enormous :-(((((

    Thanks a Million!

  26. Manasi says:

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