使用 PowerShell 重置 SharePoint 2013/2016 中的搜索索引
问题: SharePoint 2013 搜索爬网过程陷入困境,我们必须重置损坏的搜索索引。
解决方案:按照以下步骤重置 SharePoint Server 中的搜索索引。
- 转到 SharePoint 管理中心 >> 服务应用程序
- 选择您的搜索服务应用程序
在“搜索管理”页面上,单击左侧导航菜单的爬网部分下的“索引重置”链接。
- 在索引重置页面中,单击“立即重置”按钮以重置 SharePoint 2013 中的搜索索引。
在重置搜索索引之前,请确保没有搜索爬行正在进行中 - 停止所有搜索爬行,禁用连续爬行 - 否则,索引重置可能会卡住!索引重置后,您必须运行完整爬网才能启用搜索结果!
用于重置 SharePoint 2013 中索引的 PowerShell 脚本:
有时,出于以下原因,您可能必须使用 PowerShell 来执行此操作:
- 当您尝试从 Web UI 重置搜索索引时,您会收到大索引超时错误
- 您可能只想部分重置某些内容源的索引
使用 PowerShell 重置 SharePoint 2013 中的搜索索引:
以下是部分重置搜索索引的 PowerShell(重置特定内容源的搜索索引):
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
$ContentSource.StartAddresses.Clear()
#Re-add the start address to content source
ForEach ($Address in $StartAddresses ){ $ContentSource.StartAddresses.Add($Address) }
重置 SharePoint 2013 搜索索引:
要使用 PowerShell 完全重置 SharePoint 2013 搜索索引,请使用以下 cmdlet:
(Get-SPEnterpriseSearchServiceApplication).reset($true, $true)
其中 $True 参数表示:禁用警报并忽略超时错误。
如果仍然出现超时错误,请清除 SharePoint 配置缓存,然后重试!
相关文章:如何停止 SharePoint 搜索爬网
