I’m designing a page that should provide the user with search results showing all SharePoint sites they can access; it uses the Search Results Web Part. In other words, if they have the permission to view a site it should show up in the search results. Dead simple. SharePoint security trimming will prevent any sites from appearing in search results if the user has no permissions to view the site. The query used in the Search Results Web Part is:
To test things out I’ve created a number SharePoint sites that the user can view. Each site has been created using a custom site template that was saved to the solution gallery; i.e. the site was designed and saved to the solution gallery using the “Site site as template” setting:
With verified access to all 5 test sites for the user, I navigate to the page with the Search Results Web Part and only see one or two sites out of the 5. I check and re-check access to the sites. All good. I start thinking that maybe the search crawler hasn’t processed the sites. That’s not the case.
Stuck and hours later I come across a post or two that talks about a “TrimDuplicates” property that is set to “true” by default without any way to change it using the web part properties interface: http://thesharepointlife.com/2013/04/sharepoint-2013-search-not-display-all-results-2/. I followed the instructions in that post and that solved the problem. SharePoint is obviously thinking that each of the sites are duplicates but I haven’t yet figured out what attribute of the site SharePoint thinks is a duplicate. The site title’s are different so it may be that each has a page called “Home.aspx” and are based off the same template. Not sure yet. If anyone has the insight please share.
So if you’re using the SharePoint Online Search Results Web Part (and probably also the on-premise SharePoint Content Search Web Part?) and are not seeing the search results you expect, then it could that “TrimDuplicates” property lurking under the hood driving you crazy. Would be awesome if Microsoft are nice enough to add a “Trim Duplicates” checkbox to the web part properties interface.