Resetting Search Index in SharePoint 2013:

searchadministration_thumb2

Search is indeed a mission critical service application in SharePoint and it’s very important that it remains healthy so that you get the results in the Search center whenever you execute a search query. However, it’s quite possible that you may notice some errors in the “Crawl log” stating that the crawler is not able to crawl the contents in the content source and at times it might get even worse such that you may notice all “failures” and no “success” in the crawl logs. In scenarios like that you might have to reset the search index so that the content in the index gets flushed away after which you need to perform a full crawl so that search index component receives the newly processed items from the content processing component and writes them to the search index. Of course, directly resetting the index is not a fix for any search related issue, please ensure that you do all the necessary troubleshooting steps from your end to identify and fix the issue and once you reach a point where nothing really helped, that’s when you should think about resetting the search index.

What happens when you reset the Search Index?

When you reset the search index, all the contents will be immediately removed from the search index and users will not be able to retrieve search results when they execute a search query on the search center.  Once you’re done resetting the search index, you must perform a full crawl on one or more content sources to create a new search index. Users will be able to retrieve search results again once the full crawl is finished and the new search index is created. So in a nutshell there will be a downtime when the search index is getting reset. After a search index reset, the full crawl won’t restore all the analytics features that are powered by the Analytics Processing Component. All the analytics results will be erased after resetting the search index.

When we should reset the search index?

As I already mentioned above, resetting the search index should be the final step of troubleshooting for any search related issue. However, based on my experience this when we should reset the search index ….

  1. Index is corrupted
  2. One or all index component status is degraded
  3. You crawl completed successfully but you are not getting the search results.
  4. When you move the index location
  5. When Index location run out of space.
  6. In a scenario where we have Index partitions spread across multiple servers and the indexed document count is out of sync. For example, we have 2 servers set as index partitions, server 1 has 150K indexed documents and server2 has 145k index documents
  7. If we make any changes to search topology such as removing the search components ,adding the components & activating a different search topology

 Alright, now let’s take a look at the steps to reset the search index …

Pre-requisites: 

Please ensure that you take care of the below mentioned pre-requisites before resetting the search index .Failing to do so will cause adverse effects and at worst case you may end up recreating the entire search service application.

  1. Make sure the crawl status for each content source is “Idle”. If any crawl is running, wait for the crawl to complete or follow the steps to “Stop the active crawls” below.
  2. Make sure continuous crawl for content sources is disabled [if applicable].This step is only specific to SharePoint 2013 and above.
  3. Make sure the crawl rate is 0
  4. Make sure background activity status is “None” on search administration page.

Stopping the Active Crawl(s):

  1. Navigate to search administration page.
  2. Click on Content Sources link towards your left hand side as shown in the image below.

4

3. If any content source is crawling, click on the drop down of the content source and click on “Stop Crawl”.

Disable Continuous Crawl:

  1. Navigate to search administration page.
  2. Navigate to Content Sources link appearing on quick launch.

4

3. Click on the drop down and select “Disable Continuous Crawl” to disable it.

5

4. Click “Ok” when below warning message appears.

6

5. Follow the same steps to disable continuous crawl for other content sources. Finally, all the content sources would show “Idle” status as shown in the image below.

7

Suspend Search Service Application:

This step is to ensure that there is no crawling activity in place while we perform the Index reset.

  1. Open SharePoint Management Shell using service account
  2. Run the below command.

Suspend-SPEnterpriseSearchServiceApplication “Search Service Application Name”

Note: If you don’t know the name of search service application, you can get it by running below command before executing the above command.

Get-SPServiceApplication | Where-Object {$_.TypeName –eq “Search Service Application”}

After suspending the search application, search administration page will show the status as “Paused for: External request” as shown in the image below.

8

 Ensure Crawl Rate is 0:

  1. Navigate to search administration page.
  2. Check the Recent Crawl rate.

9

Ensure Crawler Background Activity is none:

  1. Navigate to search administration page.
  2. Check the status of the Crawler background activity and ensure it shows as “none” as shown in the image below.

10

Once the necessary pre-requisites are taken care, please follow the below steps to perform an Index Reset.

There are 2 ways to perform Index reset.

Using UI [User Interface]: This method can be used when the indexed content in your farm is not much in size i.e. index size is not huge and also when you don’t have large content sources.

Using PowerShell: UI method is not recommended for SharePoint farms with large search index. [i.e. huge count of searchable/indexed documents]. Using the UI method in large farms for resetting the search index can result in time out error. In such cases, we need to use PowerShell method to reset the index.

USING UI:

  1. Navigate to SharePoint Central Administration.
  2. Under “Application Management” category, click on “Manage Service Applications”.
  3. Find out “Search Service Application” and click on the Search service application.
  4. In the quick launch, click on “Index Reset

reset-crawl-index-sharepoint-2013

5. Click on confirm once done .

USING POWERSHELL:

  1. Login to the SharePoint server using Administrator credentials.
  2. Open “SharePoint management shell” with elevated permissions.
  3. Run the below command to reset search index.

12

Post Index Reset Steps:

  1. Check whether the number of searchable items is 0.
  2. Resume the search service application by running the command shown in the screenshot below.

133. Enable “continuous crawl” for the content sources if it was enabled prior to index reset.

4. Run full crawl for the content sources one by one.

This confirms that you’re done resetting the Search index successfully and please keep monitoring the full crawl and ensure that it doesn’t get stuck in the middle. The time duration for the full crawl depends on the size of the content source, if you have very large content sources then it might take days for the full crawl to complete successfully. Once done, please verify the search results and ensure that they return fine. Also check the “Crawl log” and make sure you’re not seeing any errors this time.

Thanks for reading this post …..Happy SharePointing!!!

Advertisements

PowerShell script for generating the site collections list with multiple administrators

powershell.png

Running this script will generate a report which displays the list of site collections that has multiple site collection administrators and will also display the total number of users who have access to those site collections.

Add-PSSnapin microsoft.sharepoint.powershell -ErrorAction SilentlyContinue

Add-Content “Sites.csv” -Value “SiteCollection Name,SiteCollection URL, SiteCollection Administrators, Users Count,Usage in MB”

$webApp = Get-SPWebApplication

foreach($webapps in $webapp)

{

foreach ($SiteCollection in $webApps.Sites)

{

$url = $SiteCollection.Url

$webs = Get-SPWeb $URL

[boolean] $WriteToFile = $true

$weburl = $SiteCollection.OpenWeb()

$siteowner = “”

foreach ($siteAdmin in $weburl.SiteAdministrators)

{

$siteowner = $siteAdmin.DisplayName + “|” + $siteowner

}

foreach($web in $webs)

{

#Grab all users in the site collections

$siteUserCnt = $web.AllUsers.Count

$Siteurl = $web.Url

$siteTitle = $web.Title

$site = Get-SPSite  $Siteurl

$siteusage = $site.Usage.Storage/1MB

Add-Content -Path “Sites.csv” -Value “$siteTitle,$Siteurl,$siteowner,$siteUserCnt,$siteusage”

$web.Dispose()

}

}

}

Thanks for using this script …..Happy SharePointing!!!!

Recording of Webinar Session on SharePoint Architectural Models:

thumbnail

For those who missed my session yesterday , please find the link for the video recording below .

Webinar Recording on SharePoint Architectural Models

Thanks once again for attending my session yesterday and will see you all soon in different webinar shorlty .

Happy SharePointing!!!!