Remove and Add Index Partition – SharePoint 2013

Some times you will see that One of the index partition replica may showed as degraded with Yellow icon.  According to Microsoft this happens when the server has not completed the index replication or “Propogation” to its replica.  If this optiosn stays for long you can easily fix it.  You can use the script below.  In my example the server also had query component running on the same server.

 

Removing the Index Partition Replica

Add-PSSnapin Microsoft.SharePoint.PowerShell -ea 0 
#set Search Service Application
$ssa = Get-SPEnterpriseSearchServiceApplication
$active = Get-SPEnterpriseSearchTopology -SearchApplication $ssa -Active

 

Get-SPEnterpriseSearchComponent -SearchTopology $active | Out-File E:\TOPOLOGY4.TXT
NOTEPAD E:\TOPOLOGY4.TXT

#Note Down the IDs for the components and replace in below lines.

#copy the existing topology
$clone = New-SPEnterpriseSearchTopology -SearchApplication $ssa -Clone -SearchTopology $active

#remove the bad component, placing the name where [BAD COMPONENT NAME] is... remove the []
$ComponentID = (Get-SPEnterpriseSearchComponent -SearchTopology $clone -Identity "33e8886b-2bb6-4e18-8412-668d0e93906b").componentID
Remove-SPEnterpriseSearchComponent -Identity $ComponentID.GUID -SearchTopology $clone -confirm:$false

$ComponentID = (Get-SPEnterpriseSearchComponent -SearchTopology $clone -Identity "5bf9c520-3632-46e6-976b-f97a975fad1f").componentID
Remove-SPEnterpriseSearchComponent -Identity $ComponentID.GUID -SearchTopology $clone -confirm:$false

$ssa.PauseForIndexRepartitioning()
Set-SPEnterpriseSearchTopology -identity $clone
$ssa.ResumeAfterIndexRepartitioning()
 

Adding Index Partition Replica Back to the Topology

It would be better from now to go to bad index server, and re-create the index folder drive and probably reboot it.  Use the below script to add it back to the search configuration.

Add-PSSnapin Microsoft.SharePoint.PowerShell -ea 0 
#set Search Service Application
$ssa = Get-SPEnterpriseSearchServiceApplication
$active = Get-SPEnterpriseSearchTopology -SearchApplication $ssa -Active

#copy the existing topology
$clone = New-SPEnterpriseSearchTopology -SearchApplication $ssa -Clone -SearchTopology $active

#New-SPEnterpriseSearchQueryProcessingComponent -SearchTopology $clone -SearchServiceInstance "Server1"
#New-SPEnterpriseSearchIndexComponent -SearchTopology $clone -SearchServiceInstance "Server1" -IndexPartition 0 -RootDirectory "I:\SearchIndex"

$ssa.PauseForIndexRepartitioning()
Set-SPEnterpriseSearchTopology -identity $clone
$ssa.ResumeAfterIndexRepartitioning()
Advertisements

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