SharePoint Search Thesaurus not getting updated

SharePoint search has a feature called Thesaurus which helps us to add synonyms to the keywords via a file into the search system, post updating it, the search will include these synonyms in the Query automatically along with the actual keyword searched on the site.

 

How to Inject Thesaurus into Search System ?
Create a Key-Synonym pair .csv file and update it into search system
Syntax:
Key Synonym Language
Drinks Coffee en

$searchApp = Get-SPEnterpriseSearchServiceApplication
Import-SPEnterpriseSearchThesaurus -SearchApplication $searchApp -Filename "\\server1\Synonyms.csv"

Incase if you don't see the new Synonyms being updated or no results returned for the synonym.

Login to the Query servers and check the below location to verify if the Thesaurus file is updated or not.
C:\Program Files\Microsoft Office Servers\16.0\Data\Office Server\Applications\Search\Repository\Journal

There could be multiple Thesaurus folders (two per SSA) and we need to look for the recently modified folders.
File 1 :Microsoft.UserDictionaries.Thesaurus.LanguageIndependent.dll
File 2 :Microsoft.UserDictionaries.Thesaurus.Languagedependent.dll

Incase if these are not updated, then Thesaurus won’t work. Need logs collection to understand why.

 

In one case scenario, we observed that the Crawler server will have the files updated recently but not the Query servers, then this an issue with the replication to other Query servers.
Further log analysis revealed the that the Search System was missing the Primary Host Controller, which is responsible to replicate these files to all other search servers.

"Unable to sync primary changes. Primary HostController URL is Null. Will retry in 30 sec"

 

We collected the Host controller details and found that none of the search server is set as Primary.
Get-SPEnterpriseSearchHostController | select Server, PrimaryHostController, HostControllerURL

Server PrimaryHostController HostControllerURL
------ --------------------- -----------------
SPServer Name=server1 False net.tcp://server1/ce...
SPServer Name=server2 False net.tcp://server2/ce...
SPServer Name=server3 False net.tcp://server3/ce...
SPServer Name=server4 False net.tcp://server4/ce...

We then set one of the server as Primary Host controller
$ssi = Get-SPEnterpriseSearchServiceInstance 09f85228-90fa-44a7-8629-1985f0179b55
Set-SPEnterpriseSearchPrimaryHostController $ssi

Server PrimaryHostController HostControllerURL
------ --------------------- -----------------
SPServer Name=server1 False net.tcp://server1/ce...
SPServer Name=server2 True net.tcp://server2/ce...
SPServer Name=server3 False net.tcp://server3/ce...
SPServer Name=server4 False net.tcp://server4/ce...

Restarted HostController service on all search servers and it fixed the replication issue.