Monday, May 8, 2017

How to enable results from private groups on an Enterprise Search Center


Ever since private Office 365 Groups were launched we have been troubled with search in these sites. First it didn't work at all, but later Microsoft made it work in the site itself, in Delve and on the SharePoint home page. Seems they forgot about the Enterprise Search Center.

Note: This is not an issue with Public Office 365 Groups- and seems to work in First release tenants as well

I have previously written about how to get results from private Office 365 Groups using REST, but for the vast majority of people out there you probably want to enable this on your Enterprise Search Center as well. If you have an issue with this, here’s how to make this work.
The gist of it is to set a property on the actual search query named EnableDynamicGroups. This property is hidden inside the DataProviderJSON property of the search result web part definition, and is not that easy to set. The approach taken follows my old post of of turning off duplicate trimming – which later was enabled in the UI.

This time around my sample is using Office PnP PowerShell, but you should be able to adapt it to CSOM if you want, or manually edit the .webpart file if that’s your poison.

The sample assumes your result page is named result.aspx, and that the search results web part is named “Search Results”. Enjoy!

# Result page
$pageUrl = "/sites/enterprisesearch/Pages/results.aspx"

#Check out file
Set-PnPFileCheckedOut -Url $pageUrl
$resultWP = Get-PnPWebPart -ServerRelativePageUrl $pageUrl -Identity "Search Results"
$dataProvider = ConvertFrom-Json $resultWP.WebPart.Properties["DataProviderJSON"]

$ht = @{}
$ | Foreach { $ht[$_.Name] = $_.Value }

$ht["EnableDynamicGroups"] = $true
$dataProvider.Properties = $ht
$dataProvider.PropertiesJSON = ConvertTo-Json $dataProvider.Properties -Compress

$dpJSON = ConvertTo-Json $dataProvider -Compress

# Persist the changes
Set-PnPWebPartProperty -ServerRelativePageUrl $pageUrl -Identity $resultWP.Id -Key "DataProviderJSON" -Value $dpJSON

#Check in file
Set-PnPFileCheckedIn -Url $pageUrl -CheckinType MajorCheckIn


  1. So, to summarize, I think you're saying that by default, content from Office 365 Group -generated sites doesn't surface in the Enterprise Search Center without running this Powershell today? This is madness!

    I'm also inferring that this is only an issue with so-called "private" groups? Does content from "public" Office 365 Group -generated sites already show in the Enterprise Search Center by default?


    1. Correct that it only pertains to private groups. Results from public groups should appear just fine. I added a short intro to the post about this.

      Microsoft could easily fix it for new search centers, but automagically doing it on existing sites - editing people pages might not be that easy.

      The real issue is that those items are hidden unless that weird property is added - and I have no idea why it's like that. But might be a good engineering/marketing reason behind it.

      So today, you have to "patch" every single search result/content search webpart out there if you want results from private groups to appear.

    2. I think, we need to patch only the search results webpart, content search webpart appears to pull items from private groups.


    3. Interesting, and have to test it :)

    4. Ok.. this is interesting, and possibly weird. I tried in another tenant now, and I get results from private groups without any modification. So might have been fixed in first release. Would be interesting to test in another non-first release tenant.

      I've added a comment to the top about this.