Reset Search Index in SharePoint 2013 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 search index in SharePoint 2013.

  • Go to SharePoint 2013 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.
    Reset Search Index in SharePoint 2013
  • In the index reset page, click on “Reset Now” button to reset search index in SharePoint 2013.
Before resetting search index, make sure no search crawls are in progress – Stop all search crawls, disable continuous crawl – otherwise, index reset may get stuck! After index reset, You must run full crawl to enable search results!

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 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.

If you still get Timeout errors, Clear SharePoint configuration cache and then try again!

Related post: How to Stop SharePoint Search Crawls

Salaudeen Rajack

Salaudeen Rajack is a SharePoint Architect with Two decades of SharePoint Experience. He loves sharing his knowledge and experiences with the SharePoint community, through his real-world articles!

Leave a Reply