Tuesday, July 29, 2014

Create a new the crawl database and replace the old or corrupted crawl database in SharePoint 2013 Search

Recently the crawl database in sharepoint search got corrupted.   After we fixed the indexes, it kept getting corrupted so we just recreated the database and the issues went away.  Here are the steps and power shell.


#You will need to change the search service application name, also your sql server name, and the guid of you crawl store. 




Add-PSSnapin Microsoft.SharePoint.PowerShell


#List all crawl database:


Get-SPEnterpriseSearchCrawlDatabase -SearchApplication "Search service Application"




#Create a new Crawl database: 

New-SPEnterpriseSearchCrawlDatabase -DatabaseName "Search_Service_Application_CrawlStoreDB" -DatabaseServer "SQLServerName" -SearchApplication "Search Service Application"




#Delete the crawl store that is corrupted or old.

$ssa = Get-SPEnterpriseSearchServiceApplication -Identity "Search service Application"
$cs = $ssa.CrawlStores


#list the crawl stores to find the corrupted or old one

$cs


#delete the old/corrupted store


$cs1 = $cs.Item("GUID of Old database")
$cs1.Delete()




# if the search is in a System paused for refactoring, use the command below to normal


#$ssa = Get-SPEnterpriseSearchServiceApplication -Identity "Search service Application"
#$ssa.ForceResume($ssa.IsPaused())