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.
$HOSTA = GET-SPENTERPRISESEARCHSERVICEINSTANCE -IDENTITY "SearchServer-2013" $HOSTB = GET-SPENTERPRISESEARCHSERVICEINSTANCE -IDENTITY "SearchServer-2013-ap" START-SPENTERPRISESEARCHSERVICEINSTANCE -IDENTITY $HOSTA START-SPENTERPRISESEARCHSERVICEINSTANCE -IDENTITY $HOSTB
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.
$host1 = "SearchServer-2013" $host2 = "SearchServer-2013-ap" $SSA = GET-SPENTERPRISESEARCHSERVICEAPPLICATION $Clone = NEW-SPENTERPRISESEARCHTOPOLOGY -SEARCHAPPLICATION $SSA New-SPEnterpriseSearchAdminComponent –SearchTopology $clone -SearchServiceInstance $host1 New-SPEnterpriseSearchContentProcessingComponent –SearchTopology $clone -SearchServiceInstance $host2 New-SPEnterpriseSearchAnalyticsProcessingComponent –SearchTopology $clone -SearchServiceInstance $host2 New-SPEnterpriseSearchCrawlComponent –SearchTopology $clone -SearchServiceInstance $host2 New-SPEnterpriseSearchIndexComponent –SearchTopology $clone -SearchServiceInstance $host1 -RootDirectory "D:\SharePointIndex\Partition 0" New-SPEnterpriseSearchIndexComponent –SearchTopology $clone -SearchServiceInstance $host2 -RootDirectory "D:\SharePointIndex\Partition 0" New-SPEnterpriseSearchQueryProcessingComponent –SearchTopology $clone -SearchServiceInstance $host1 New-SPEnterpriseSearchQueryProcessingComponent –SearchTopology $clone -SearchServiceInstance $host2 SET-SPENTERPRISESEARCHTOPOLOGY -IDENTITY $Clone
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.
$ssa = Get-SPEnterpriseSearchServiceApplication $active = Get-SPEnterpriseSearchTopology -SearchApplication $ssa -Active $clone = New-SPEnterpriseSearchTopology -SearchApplication $ssa -Clone –SearchTopology $active
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
Get-SPEnterpriseSearchComponent -SearchTopology $active
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.
New-SPEnterpriseSearchCrawlComponent -SearchTopology $clone -SearchServiceInstance SearchServer02 New-SPEnterpriseSearchContentProcessingComponent -SearchTopology $clone -SearchServiceInstance SearchServer02 New-SPEnterpriseSearchIndexComponent -SearchTopology $clone -SearchServiceInstance SearchServer02 New-SPEnterpriseSearchAdminComponent -SearchTopology $clone -SearchServiceInstance SearchServer02 New-SPEnterpriseSearchAnalyticsProcessingComponent -SearchTopology $clone -SearchServiceInstance SearchServer02 New-SPEnterpriseSearchQueryProcessingComponent -SearchTopology $clone -SearchServiceInstance SearchServer02
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
Get-SPEnterpriseSearchComponent -SearchTopology $clone
Step 6: remove the unwanted components. Notice, how this removes them from the $clone not the $active
Remove-SPEnterpriseSearchComponent -Identity 5ea6e37d-6fb2-4cec-8a32-225a40128048 -SearchTopology $clone Remove-SPEnterpriseSearchComponent -Identity 31ea3e53-34f0-40c0-b595-cd9350369e4d -SearchTopology $clone Remove-SPEnterpriseSearchComponent -Identity 056a4795-6769-4a8b-904c-e6b29cbcdb96 -SearchTopology $clone Remove-SPEnterpriseSearchComponent -Identity 16fce40e-2057-46b1-8512-ae33166129b9 -SearchTopology $clone Remove-SPEnterpriseSearchComponent -Identity 9d4a6254-dc96-444d-98cd-d580d63b4503 -SearchTopology $clone Remove-SPEnterpriseSearchComponent -Identity 89434df4-524d-4767-b169-78f33c8106bc -SearchTopology $clone
Step 7: Set the clone as the active topology
Set-SPEnterpriseSearchTopology -Identity $clone
and finally, if you ever just want to check the status of your search topology just run this little nugget
$ssa = Get-SPEnterpriseSearchServiceApplication Get-SPEnterpriseSearchStatus -Text -SearchApplication $ssa