Forum Discussion
SharePoint Online Search REST API inconsistent results
We are executing the following search rest API call to retrieve all documents libraries in current site and all sub-sites. Sites are 'Modern Team Sites' which means these are connected to O365 Groups.
Search Results: Case 1
When a user who is a member of O365 Group lands on the page, the query executes and all document libraries are displayed.
Search results: Case 2
When a user who isn't a member of O365 Group lands on the page, search results are empty. No libraries are retrieved. This is even though user is a site collection administrator. As soon as we add the user to 'Office 365 Group', search results start coming up and disappear when the user is removed from the group.
This behaviour is also manifested in out-of-the-box 'HighlightedContent' webpart if we configure the webpart to show document libraries by using the ContentClass=STS_List_DocumentLibrary managed property.
https://<tenant>.sharepoint.com/sites/ModernTeam/_api/search/query?queryText='contentclass:STS_List_DocumentLibrary Path:https://<tenant>.sharepoint.com/sites/ModernTeam'&Properties='EnableDynamicGroups:true,EnableMultiGeoSearch:true,ClientFunction:AllResults'&selectproperties='Title, Path, ParentLink, WebTemplate, WebId, ContentClass, Description'&trimduplicates=false