-->

Thursday, 5 September 2013

Sharepoint 2013 - Working with Thesaurus And Synonyms

I wanted that my search center should return the results with the synonyms for the particular search keyword. I tried to do it the way we do in Sharepoint 2010.
Locate the thesaurus file from %ProgramFiles%\Microsoft Office Servers\14.0\Data\Office Server\Applications\GUID-query-0\Config, where GUID is the GUID of the new Search service application. Something like mentioned here.

It was pretty good where we had two functionalities "Replacement Sets" & "Expansion Sets", But for Sharepoint 2013 these they have eliminated it.

Below are the steps to do that in Sharepoint 2013
 1. Create a thesaurus file
 2. Install the Thesaurus file
 3. Check the results

 1. Create a thesaurus file
 Create a .csv file with the columns Key, Synonym and Language.
Key - Term (single or multiple words) that you want to trigger a synonym for when the term occurs in a query
Synonym - Synonym (single or multiple words) that you want to add to the query if the term specified in the Key column occurs in a quer
Language(Optional) - Abbreviation for the language for which the synonym should apply

This is how my thesaurus.csv file will look.


 2. Install the thesaurus File
 This can be done using powershell

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

<Path> specifies the full UNC path of the .csv file (the thesaurus) to be imported.

3. Check The Results
As you can see in the figure, whenever i want to search for "Internet Explorer" it should return the results with "IE" or "IE5" or "IE6" or "IE7"


One more thing to note over here is, if i search for "IE" or "IE5" or "IE6" or "IE7" it will return only that particular results.


Key Points:
  1. I find the new approach in SharePoint 2013 a bit cumbersome, only good thing about it was power shell support and it does not require restart of Search service
  2. It does not have Replacement Set option, so we cannot replace the keyword search with our option. For example, I cannot replace the search with "NT5" keyword search with the "Windows 2000" and "W2K". Which was possible with SharePoint 2010
  3. It is not as extensible as expansion set. Here only one to one mapping is possible. For example, i had to write 4 entries to include the search for IE5,IE6,IE7 and IE when user searches for "Internet Explorer"
Happy Sharepointing !

Please do Share/Like/Comment if this article was helpful.