当前位置:网站首页 > 更多 > 玩电脑 > 正文

[玩转系统] 默认视图缺失 - 增量搜索抓取卡住 - 解决方案

作者:精品下载站 日期:2024-12-14 13:47:02 浏览:16 分类:玩电脑

默认视图缺失 - 增量搜索抓取卡住 - 解决方案


问题: SharePoint 增量爬网停留在特定时间点 - 没有更改爬网状态:“增量爬网”。搜索爬网日志中没有进展。搜索爬网中没有包含新项目。

根本原因:某些列表和库中缺少默认视图文件/关联。当爬虫爬行这些列表和库时,它就卡在那里了!我尝试从“查看所有网站内容”页面浏览这些列表和库。发现这些库指向它们的设置页面,而不是“AllItems.aspx”!

解决方案:使用 PowerShell 创建默认视图:


Add-PSSnapin microsoft.sharepoint.powershell -ErrorAction SilentlyContinue

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

$WebApp = Get-SPWebApplication "https://sharepoint.crescent.com"

#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
                    }
                 }
             }
             $web.dispose()
       }
        $site.dispose()
    }
  
#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);
    
    $web.dispose();
}

#Export the result Array to CSV file
$ResultsColl | Export-CSV "D:\NoDefaultView.csv" -NoTypeInformation 
   
write-host "Script execution has been Completed!"

上面的脚本在缺少的列表上创建一个默认视图。运行脚本并再次启动爬网。

您需要 登录账户 后才能发表评论

取消回复欢迎 发表评论:

关灯