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 
  • In Search Administration page, Click on "Index Reset" link under 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

#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
Reset Search Index in SharePoint 2013 using Powershell Reset Search Index in SharePoint 2013 using Powershell Reviewed by Salaudeen Rajack on May 26, 2015 Rating: 5

No comments:

Please Login and comment to get your questions answered!

Powered by Blogger.