How To Add Synonyms And Acronyms To Increase The Search Results Relevancy In SharePoint 2016 Search

Introduction

In this article, you will understand how to add synonyms and acronyms in SharePoint 2016 On Premises using PowerShell scripts in SharePoint Search.

Description and Detailed Instructions

SharePoint 2016 is powerful Search Engine where we can add sets of synonyms and acronyms and their values so that when a user clicks on short formed keywords – the result sources from expanded or the given value would also be included, thus improving relevancy.

The syntax has to be followed by KEY, SYNONYM, LANGUAGE. This is mandatory field to be added on top.  

After the above, you can add our keys and synonyms while Language is an optional parameter.

Sample words added:

  • "AKA, also known as"
  • "AMEX, American Express"
  • "BOFA, Bank Of America"
  • "IT, Information Technology"
  • "DE , Deutsch"

After that, this has to be saved as CSV file and then the below PowerShell scripts has to be executed. 

  1. $searchApp = Get-SPEnterpriseSearchServiceApplication  
  2. Import-SPEnterpriseSearchThesaurus -SearchApplication $searchApp -Filename “CSVFileLocation”   

Get-SPEnterpriseSearchServiceApplication - This command will get the Search Application that is running on the machine. You will have to select the Search Service Application if there are more Search Services, by their identity. 

Then, the Import-SPEnterpriseSearchThesaurus command will import the thesaurus' data from the given file location. 

Output

SharePoint 2016

After this, you need to wait at least 15 minutes to replicate the change. Now, if you search the words “AKA”, the results would be included from Also Known As if exists. 

But then, if the results of this are given less weightage, that can be seen using CeresShell Scripts. 

  1. PowerShell_ISE –file "C:\Program Files\Microsoft Office Servers\16.0\Search\Scripts\ceresshell.ps1"  
  2. Connect-System -Uri  (Get-SPEnterpriseSearchServiceApplication).SystemManagerLocations[0] -ServiceIdentity (Get-SPEnterpriseSearchService).ProcessIdentity  
  3. Connect-Engine -NodeTypes InterActionEngine    

Output

SharePoint 2016

Please note that environment is SharePoint 2016, selected file location is 16.0, and it would be differing for- SP version is 2013 (15.0). 

After this, use Get-Flow "Microsoft.SharePointSearchProviderFlow" > “OutputFileLocation"                                                                

Command to get the SharePoint Weightage for synonyms. 

  1. <Property name="synonymWeight" value="0.2" />  

This can be increased to “1” so that synonyms results appear in the results predominantly.

After changing this value to 1, update the "Microsoft.SharePointSearchProviderFlow"  

  1. Remove-Flow "Microsoft.SharePointSearchProviderFlow"  
  2. Get-Content "UpdatedFileLocation" | Out-String | Add-Flow "Microsoft.SharePointSearchProviderFlow"  
  3. Stop-Flow –FlowName "Microsoft.SharePointSearchProviderFlow" –ForceAll  

The above command would be successfully executed if there is no error in the command and after you can use the Get-Flow "Microsoft.SharePointSearchProviderFlow" > “OutputFileLocation"

To verify if the value has been updated or not.

Please wait for at least 15 minutes now and do a Search. This change should be reflecting on the Enterprise Search results.

Final Output Result

SharePoint 2016

Conclusion

You have learned how to add synonyms and acronyms to increase the Search results relevancy and this improve user experience in SharePoint 2016 Search.

X

Build smarter apps with Machine Learning, Bots, Cognitive Services - Start free.

Start Learning Now