Show duplicate content in SharePoint Online Search Results

Are you not seeing all results when searching for documents in Sharepoint? Are you confident that there is another, newer version? Then probably it’s filtered out by Sharepoints duplicate content removal in the search results. A document does not have to be 100% similar to be flagged as duplicate, similar documents or sites seems to be removed also.

You can’t change this behavior for the default search boxes in Sharepoint online (the one in the top left corner), but you can change the classis search page at (https://contoso.sharepoint.com/search).

Disabling Duplicate Removal

To disable the duplicate removal in the classic search page we need to use a javascript to create a checkbox that allows you to show or hide the duplicate content.

Go the classic search page and edit the page. We are going to add a Script Editor web part to the search page and insert the code below.  Click on Add Web Part and go to the Category  Media and Content and select the Script Editor

// 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>

Save and publish the page. You can now search for content with or without the filtering of duplicates.

References : Peter Angehrn

Get more stuff like this

IT, Office365, Smart Home, PowerShell and Blogging Tips

I hate spam to, so you can unsubscribe at any time.

Leave a Comment