2014-03-10

When you are working with Search in SharePoint 2013 you no longer have the luxury of using the GUI to modify search topology. Now we have to directly modify a topology using a clone in PowerShell.
At a high level we have the:

  • Search Service Application
  • Search Topology
  • Search Instance on each Server in the search topology

We also have the following components:

  • Admin
  • Crawler
  • Content Processing
  • Analytics Processing
  • Query Processing
  • Index

When we want to change the topology of a search service application such as:

  • Change the index location on the index component
  • Add a index replica on another server in the farm
  • Add additional components to other servers in the farm
  • Remove components

We have to first clone the active topology, make our changes to the clone and then activate the clone. However, there is a difference between using the Clone() method on the SSA and using the
New-SPEnterpriseSearchToplogy –Clone switch. One gives your newly cloned components IDs where the other does not.
When we create a clone by doing the following

$ssa = get-spenterprisesearchserviceapplication
$clone = $ssa.ActiveTopology.Clone()

We get this when we look at the topology:

image

And we get this when we look at the components in the cloned topology: (Get-SPEnterpriseSearchComponent  -SearchTopology $clone)

image

As you can see above, all of our components have blank IDs. If we wanted to remove a component from the topology how would we identify which component to remove? The Remove-SPEnterpriseSearchComponent -Identity switch wants an ID of the component to remove so we need to get a valid ID in order for this work.
Using the above method we can easily add additional components to the topology but we cannot remove.

Solution

After you capture your SSA run the following command:

$active = Get-SPEnterpriseSearchTopology -Active -SearchApplication $ssa
$Clone = New-SPEnterpriseSearchTopology -SearchApplication $ssa -Clone -SearchTopology $active

Now we get this: 

image

Now we have an ID field that we can use to easily remove a component from the topology.

{Kam]

About the author 

Kameron Berget