Reset Search Index in SharePoint 2013 / 2016 using PowerShell
Problem: SharePoint 2013 search crawling process got stuck, and we got to reset the corrupted search index.
Solution: Follow these steps to reset the search index in SharePoint Server.
- Go to SharePoint Central Administration >> Service ApplicationsĀ
- Pick your Search Service ApplicationĀ
- On the Search Administration page, click on the “Index Reset” link under the crawling section of the left navigation menu.
- In the index reset page, click on “Reset Now” button to reset search index in SharePoint 2013.
PowerShell script to reset index in SharePoint 2013:
At times, you may have to do it with PowerShell for reasons, such as:
- When you try to reset search index from Web UI, you get timeouts error on large index
- You may want to partially reset index for only certain content source
Reset search index in SharePoint 2013 with PowerShell:
Here is the PowerShell to reset the search index partially (Reset search index for a specific content source):
Add-PSSnapin Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue
#Get Search service application
$ssa = Get-SPEnterpriseSearchServiceApplication
#Content Source Name
$ContentSourceName = "Crescent Portal"
#Get the content source
$ContentSource = Get-SPEnterpriseSearchCrawlContentSource -Identity $ContentSourceName -SearchApplication $SSA
#Get Each Start Address
$StartAddresses = $ContentSource.StartAddresses | ForEach-Object { $_.OriginalString }
#Clear Indexed content starts with custom contnet source
$ContentSource.StartAddresses.Clear()
#Re-add the start address to content source
ForEach ($Address in $StartAddresses ){ $ContentSource.StartAddresses.Add($Address) }
Reset SharePoint 2013 Search Index:
To Reset SharePoint 2013 search index completely using PowerShell, use this cmdlet:
(Get-SPEnterpriseSearchServiceApplication).reset($true, $true)
Where the $True parameter denotes: Disable Alerts & Ignore Timeout error.
Related post: How to Stop SharePoint Search Crawls