How to restart a query component in SharePoint 2010?
Sometimes you might have seen this warning in event log
Event ID: 2587
The following conditions are currently affecting index propagation to this server for search service application ‘ Search Service’: 1. Query 0 has been disabled so that crawls can continue. It may be recovered via the Restart-SPEnterpriseSearchQueryComponent command in PowerShell.
It indicates that SharePoint 2010 Search Query Component has been disabled and it needs to be restarted, this might occur due to index corruption. You might also see errors/warnings with Event ID 2581 and Event ID 74. When you get on to central admin and navigate to the Search administration screen, you might notice that the query component is disabled.
So How do you restart it? You can do it using the Restart-SPEnterpriseSearchQueryComponet, here it the power shell powershell script to do it
Add-PSSnapin Microsoft.SharePoint.Powershell
$S = Get-SPEnterpriseSearchServiceApplication -Identity ” Search Service Name”
$Q =$S.QueryTopologies
$C =Get-SPEnterpriseSearchQueryComponent -QueryTopology $Q.ActiveTopology
$C | fl Name,State
$C[0] | Restart-SPEnterpriseSearchQueryComponent
Once you run the script, if you go back to central admin and search administration page, you would see the status of the query component change to recovering and eventually the status should change to online.



Note for the PS noobs like me.
If you have multiple query components, the command “$C | fl Name,State” will give you multiple results; something like:
Name : xxxxxx-query1
State: Ready
Name : xxxxxx-query2
State: Offline
Name : xxxxxx-query3
State: Ready
So in the command “$C[0] | Restart-SPEnterpriseSearchQueryComponent” you have to replace the “0″ in “[0]” by the number of the component you want to restart from the array. In this case, the second one is offline, so my command to restart it would be “$C[1] | Restart-SPEnterpriseSearchQueryComponent”