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

[玩转系统] SharePoint Online:如何从搜索结果中排除网站?

作者:精品下载站 日期:2024-12-14 21:17:28 浏览:16 分类:玩电脑

SharePoint Online:如何从搜索结果中排除网站?


要求:从 SharePoint Online 的搜索中排除网站。

如何从搜索中排除 SharePoint Online 网站?

默认情况下,SharePoint Online 搜索结果经过安全修整,用户可以从他们有权访问的所有网站获取搜索结果。但是,在某些情况下,您可能希望阻止某个网站出现在搜索结果中,例如,我们有一个用于备份目的的文档存档网站集,并且我们不希望该网站的结果出现在全局搜索中结果。在本文中,我们将讨论如何从 SharePoint Online 的搜索结果中排除网站。

  1. 打开您想要阻止出现在搜索结果中的 SharePoint Online 网站。
  2. 单击“设置”图标,然后选择“站点设置”。
  3. 在“站点设置”页面上,单击“搜索”部分下的“搜索和离线可用性”链接。

    [玩转系统] SharePoint Online:如何从搜索结果中排除网站?

  4. 设置“允许该网站出现在搜索结果中吗?”在“索引站点内容”部分中将选项设置为“否”,然后单击“确定”。

    [玩转系统] SharePoint Online:如何从搜索结果中排除网站?

这些更改将在下次抓取后生效 - 该网站及其所有内容将不会出现在搜索结果中。

SharePoint Online:使用 PowerShell 从搜索中排除网站

要从搜索索引中排除 SharePoint Online 网站集,请使用以下 PowerShell 脚本:


#Load SharePoint Online Assemblies
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\ISAPI\Microsoft.SharePoint.Client.dll"
Add-Type -Path "C:\Program Files\Common Files\Microsoft Shared\Web Server Extensions\ISAPI\Microsoft.SharePoint.Client.Runtime.dll"
    
##Variables for Processing
$SiteUrl = "https://crescent.sharepoint.com/sites/marketing/2018"

#Get Credentials to connect
$Cred= Get-Credential
  
Try {    
    #Setup the context
    $Ctx = New-Object Microsoft.SharePoint.Client.ClientContext($SiteUrl)
    $Ctx.Credentials = New-Object Microsoft.SharePoint.Client.SharePointOnlineCredentials($Cred.Username, $Cred.Password)
     
    #Get the Web
    $Web = $Ctx.Web
    $Ctx.Load($Web)
    $Ctx.ExecuteQuery()

    If($Web.NoCrawl)
    {
        Write-host -f Yellow "Site is Already excluded from Search Index!"
    }
    Else
    {
        #Exclude Site from Search
        $Web.NoCrawl = $True
        $Web.Update()
        $Ctx.ExecuteQuery()
        Write-host -f Green "Site is Excluded from Search Index Successfully!"
    }
}
catch {
    write-host "Error: $($_.Exception.Message)" -foregroundcolor Red
}

PnP PowerShell 从 SharePoint Online 的搜索中排除网站集

我们还可以使用 PnP PowerShell 从 SharePoint Online 搜索索引中排除网站。


#Parameter
$SiteURL= "https://crescent.sharepoint.com/sites/marketing"

#Connect to PnP Online
Connect-PnPOnline -Url $SiteURL -Credentials (Get-Credential)

#Exclude Root Web of the Site Collection from Search Index
$Web = Get-PnPWeb
$Web.NoCrawl = $true
$Web.Update()
Invoke-PnPQuery

这会将网站集从搜索中排除。确保您连接到网站集(而不是子网站!)。

使用查询规则从搜索结果中排除网站

以下是使用查询规则从搜索中排除内容的另一种方法:

  1. 导航到您的搜索中心。通常,位于:https://YourTenant.sharepoint.com/search/
  2. 输入一些搜索查询并单击搜索,转至搜索结果页面。
  3. 进入搜索结果页面 (Pages/results.aspx) 后,单击“设置”齿轮 >> 选择“编辑页面”。
  4. 找到“搜索结果”Web 部件,然后从其上下文菜单中选择“编辑此 Web 部件”。这将打开 Web 部件属性窗格。
  5. 在 Web 部件属性面板中,单击“更改查询”按钮。您将看到一个弹出页面来构建您的查询。
  6. 在“构建查询”对话框窗口中,在属性过滤器下拉列表中选择“路径”。将参数更改为“不开头”。对于值,选择“手动值”,然后键入要排除的站点的 URL,然后单击“添加属性过滤器”按钮。这会在“查询文本”框中附加 -Path:https://site-to-remove/*。例如:{searchboxquery} -路径:https://crescent.sharepoint.com/sites/archive/*

    [玩转系统] SharePoint Online:如何从搜索结果中排除网站?

  7. 保存、签入并发布页面!如果要排除多个网站集,请使用 OR 运算符。例如。 {searchboxquery} -路径:https://crescent.sharepoint.com/sites/archive/* 或 -路径:https://crescent.sharepoint.com/sites/backup/*

您还可以使用 SharePoint 管理中心的“删除搜索结果”页面从搜索索引中删除现有搜索结果!如何从 SharePoint Online 中删除搜索结果?

结论:

从 SharePoint Online 的搜索结果中排除网站是一个简单的过程,可以通过在 SharePoint 搜索管理页面上编辑网站的爬网设置来完成。通过将网站的抓取设置设置为“否”,我们可以阻止该网站出现在搜索结果中。您还可以使用 PowerShell 设置此属性来自动执行该过程。这对于包含敏感或机密信息的网站或与大多数用户不相关的网站非常有用。请记住,更改可能需要一些时间才能生效。

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

取消回复欢迎 发表评论:

关灯