Karine Bosch’s Blog

On SharePoint

In search for the Index Component


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.

My colleague Manoj Malireddy figured out how to do this:

   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"
                     select sapp;

       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";
           }
       }
   }

August 1, 2013 - Posted by | Search, SharePoint 2010

No comments yet.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: