Modifying a SharePoint 2013 or 2016 Search Topology – After Index Reset

posted in: PowerShell, Search | 0

The following blog post works best with an empty index.  In other words, it works best before your first full crawl, or immediately after you have reset the search index.  Don’t use this for a search topology where the index is populated or where the index is degraded.

 

Step1:  Load the admin Shell and instantiate the names of your servers that will be in the search topology and start the search service instance on each of the servers.

Step 2: Wait until all servers show that the service is online by running a Get-SPEnterpriseSearchServiceInstance -Identity “<servername>”.  After the instance is started, grab the current topology from the search service application and then instantiate that into an object named clone that will serve as the new search topology.  Note: it is here that you define the new components on each of the hosts.  You could add more servers than just the two, in this example, but we left it with two for ease of conversation.  Note: if all you’re doing is taking a single server search topology to a multi server topology then this is the last step.  If you are going to be modifying an existing topology that has more than one server, then do not run the last line of step 2 and continue reading this post.  Remember the old saying: Haste makes Waste, this is very true in reading and applying SharePoint blog posts to SharePoint.

IMPORTANT:  Make sure that D:\SharePointIndex\Partition 0 directory exists on both servers before running the above.  And, make sure that the directory is empty.

To modify the search topology, you need to make that clone, because you are not actually modifying the existing topology.  You are making the changes in that clone and then going to set the clone as active.  This is why you need a healthy index.

If you wanted to modify an existing topology, say you had a topology that already uses the above servers and you want to move some components around, then there are some additional things to do before running SET-SPENTERPRISESEARCHTOPOLOGY -IDENTITY $Clone

Step 3 – This step assumes that in step 2, you did not run SET-SPENTERPRISESEARCHTOPOLOGY -IDENTITY $Clone

In this step we instantiate two vairables, one to signify the active search topology and one to signify the clone that we are going to make changes.  And, once more, very important to note: the index is empty.

Notice how we got a reference to the current search service application and put it into a variable named $ssa? That is so we can create an exact clone of it using the -clone parameter.  This is similar to what we did in step two, only looks a little different.

Now, we can list out the active topology, which has not changed yet, and we can gather the component ID’s that we’re going to remove from the clone

Once we see the component ID’s that we need to move to different servers, we can make changes, in this example we’re assuming that we have a new search server named SearchServer02 that is going to run all the components by itself, versus the previous topology where there were two servers, so affectively we’re getting rid of that two server topology in this example, and we’re moving the index to the default location on the C: drive.  So here we go in step 4:

 

Step 4: Make changes to the clone

Notice how this code changes the $clone and the search service instance, services on server, is running.  If not check out step one and make sure you instantiated the service instance.

Now we can verify that the clone has all the components running in it

Step 5: take a look at the clone and get the component ID’s of the components from the previous search topology so that you can remove them and also see that the new search components are showing online on the new server

Step 6: remove the unwanted components. Notice, how this removes them from the $clone not the $active

Step 7: Set the clone as the active topology

and finally, if you ever just want to check the status of your search topology just run this little nugget

 

 

Leave a Reply