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

[玩转系统] 在 SharePoint Online 搜索结果中显示重复内容

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

在 SharePoint Online 搜索结果中显示重复内容


在 Sharepoint 中搜索文档时,您是否没有看到所有结果?您确信还有另一个更新的版本吗?然后可能会通过 Sharepoints 搜索结果中的重复内容删除功能将其过滤掉。文档不一定要 100% 相似才能被标记为重复,相似的文档或网站似乎也会被删除。

您无法更改 Sharepoint Online 中默认搜索框(左上角的搜索框)的此行为,但您可以更改分类搜索页面 (https://contoso.sharepoint.com/search)。

禁用重复删除

要在经典搜索页面中禁用重复删除,我们需要使用 JavaScript 创建一个复选框,允许您显示或隐藏重复内容。

[玩转系统] 在 SharePoint Online 搜索结果中显示重复内容

转到经典搜索页面并编辑页面。我们将向搜索页面添加一个 脚本编辑器 Web 部件,并插入以下代码。点击添加 Web 部件,然后转到类别媒体和内容,然后选择脚本编辑器

// SRC: http://www.sharepointsearch.net/disable-duplicate-removal-in-sharepoint-search/

<div id="dupframe">
<input id="duplicates" type="checkbox" value="duplicates" name="duplicates">
 <label for="duplicates">Show duplicates</label>
</div>
<script>
// Show duplicated results
 
document.getElementById('dupframe').style.float="left";
document.getElementById('dupframe').style.position="relative";
document.getElementById('dupframe').style.left="120px";
 
var is_chrome = navigator.userAgent.toLowerCase().indexOf('chrome') > -1;
if (is_chrome) {
    document.getElementById('dupframe').style.top="7px";
}
else 
{
    document.getElementById('dupframe').style.top="9px";
}
 
if (typeof Srch.U.fillKeywordQuery !== 'undefined') {
    var originalFillKeywordQuery = Srch.U.fillKeywordQuery;
    Srch.U.fillKeywordQuery = function(query, dp) {
        if (document.getElementById('duplicates').checked) {
            // Set the trim duplicates property to false
            dp.set_trimDuplicates(false);
        } else {
            // Set the trim duplicates property to true
            dp.set_trimDuplicates(true);
        }
        // Call the default function to go further with the query processing
        originalFillKeywordQuery(query, dp);
    };
}
</script>

保存并发布页面。您现在可以搜索带或不带重复项过滤的内容。

参考文献:彼得·安格恩

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

取消回复欢迎 发表评论:

关灯