Inconvenient search and modern team sites
So you created a new modern team site and you can't find it or any information stored inside through SharePoint Search.
Modern Team Sites
Modern Team Sites are the default experience to support collaboration in Office 365. They extend the basic team collaboration features with additional capabilities such as e-mail, calendar or tasks. All of that is exposed through a modern UI that makes the features easy to use.
When creating modern Team Sites, you can choose if the information stored in the site should be shared with everyone or only the site's members.
And it's the private Team Sites, that can cause some confusion.
Inconvenient modern Team Sites and search
While the site is being created, SharePoint asks you if you want to add owners and members to the site.
If you don't specify any users, you will not be able to retrieve neither the site nor any information stored inside through SharePoint Search!
If you check the crawl log, you would see that the site and its data have been indexed correctly. And yet, none of it will be returned when you try searching for it.
The missing ingredient
It turns out, that while creating modern Team Site, by default no users are set as owners or members. Because search results are security trimmed, no information about the site is returned. To fix the problem, you should specify the current user as one of the site owners.
If you're creating modern Team Sites programmatically using the Office 365 CLI, after creating the site, you need to set its owners:
# create modern Team Site o365 spo site add --type TeamSite --alias teamsite --title Team Site # set site owners o365 spo site classic set --url https://contoso.sharepoint.com/sites/teamsite --owners firstname.lastname@example.org
Despite its name, the
spo site classic setcommand works with both classic and modern site collections.
After setting site owners, you will be able to retrieve the information from the modern Team Site using search as expected.
In case you don't see changes quickly enough, request reindexing the site, either through search settings or using the
spo web reindexOffice 365 CLI command.
Big thanks to Mikael Svenson for being the second pair of eyes and helping me find out what was wrong.