Monday, May 26, 2014

Default View Missing - Incremental Search Crawl Stuck - Solution

Problem: SharePoint incremental crawl stuck at a particular point of time - without changing the crawling status from: "Crawling Incremental". No progress in search crawl log. No new items included in search crawl.

Root cause: Default view files / associations missing in some of the lists and libraries. When crawler crawls those lists and libraries it just stuck there! I tried browsing those lists and libraries from "View all Site content" page. Found those libraries were pointing to their settings page, instead of "AllItems.aspx"!

Solution: Create a Default View using PowerShell:


#Get-SPWebApplication, Get-SPWeb cmdlets for MOSS 2007
Function global:Get-SPWebApplication($WebAppURL)
 return [Microsoft.SharePoint.Administration.SPWebApplication]::Lookup($WebAppURL)

Function global:Get-SPWeb($url)
  $site= New-Object Microsoft.SharePoint.SPSite($url)
        if($site -ne $null)
    return $web

#Array to Hold Result - PSObjects
$ResultsColl = @()

$WebApp = Get-SPWebApplication ""

#Get All site collections of the Web Application 
  $SitesColl = $webApp.Sites 
  #Iterate through each site collection/sub-site
  foreach($Site in $SitesColl)
    foreach($web in $site.AllWebs)
          foreach($list in $web.lists) #Lable for Processing all lists. Otherwise, we'll get collection modified error
                if($list.hidden -eq $false)
                    if($list.defaultview -eq $null)
                     write-host $web.URL - List Name: $list.title
                     $ResultItem = New-Object PSObject
                     $ResultItem | Add-Member -MemberType NoteProperty -name "WebURL" -value $web.URL 
                     $ResultItem | Add-Member -MemberType NoteProperty -Name "ListName" -value $list.title

                     #Add the object with property to an Array
                     $ResultsColl += $ResultItem
#Process Each List and Create a View in them
#We need to process each list in this separate section 
#Because, modifying any object in the collection will thorw: Collection modified exception

foreach($Result in $ResultsColl)
    $web = Get-SPWeb $Result.WebURL
    $list = $web.Lists[$Result.ListName]
    #Create the default view
    $BaseView = $list.GetUncustomizedViewByBaseViewId(0); # Standard View
    $viewColl = $BaseView.ViewFields.ToStringCollection();
    $list.Views.Add("Default", $viewColl, $BaseView.Query, $BaseView.RowLimit, $BaseView.Paged, $true);

#Export the result Array to CSV file
$ResultsColl | Export-CSV "D:\NoDefaultView.csv" -NoTypeInformation 
write-host "Script execution has been Completed!"
The above script creates default view on list where its missing. Run the script and initiate a crawl again.

You might also like:
SharePoint Usage Reports
Usage reports, collaboration and audit for SharePoint.
Document SharePoint Farm
Automatically generate SharePoint documentation.

Check out these SharePoint products:

No comments :

Post a Comment

Please Login and comment to get your questions answered!

You might also like:

Related Posts Plugin for WordPress, Blogger...