At the company I work for, we are going to start working with synonyms in our Search results (we are still on SharePoint 2010). The synonyms will be maintained by our Content Editors team and therefore I decided to let them maintain the synonyms in the term store (Managed metadata service application), as it is done in SharePoint 2013. Every night a timer job will run to read the term store and to create the tsenu.xml file and to copy it to the \Microsoft Office Servers\14.0\Data\Office Server\ApplicationsGUID-query-0\config\tsenu.xml folder.
When our code goes in production, it goes through a DTAP process, meaning that our code needs to be deployed on dev, on test, on acceptance before it goes in production. So we have different SharePoint farms for the different environments. Although the SharePoint folders our always deployed to the same drive, the folder for the tsenu.xml can be different as one of the folders is the GUID of the Search Service Aplication. So I wanted that the timer job would figure out the correct folder using the Search topology.
SearchService s = new SearchService(“OSearch14”, SPFarm.Local);
if (s != null)
var srchApp = from SearchServiceApplication sapp in s.SearchApplications
where sapp.Name == “Enterprise Search Service Application”
SearchServiceApplication serviceApp = srchApp.FirstOrDefault();
if (serviceApp != null)
var queryComponent = serviceApp.QueryTopologies.ActiveTopology.QueryComponents.FirstOrDefault();
if (queryComponent != null)
string serverName = queryComponent.ServerName;
string directoryPath = queryComponent.IndexLocation;
string foldername = queryComponent.Name;
string configfoldername = directoryPath + “\\” + foldername + “\\Config”;