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.

Creating modern Team Site in Office 365
Creating modern Team Sites

And it’s the private Team Sites, that can cause some confusion.

While the site is being created, SharePoint asks you if you want to add owners and members to the site.

SharePoint prompting for adding owners and members while the modern Team Site is being created
Adding owners and members: more than meets the eye

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!

No results when searching for the newly created site
"Nothing here matches your 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 --owners

Despite its name, the spo site classic set command 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.

Information from the modern Team Site returned in SharePoint search results

In case you don’t see changes quickly enough, request reindexing the site, either through search settings or using the spo web reindex Office 365 CLI command.

Big thanks to Mikael Svenson for being the second pair of eyes and helping me find out what was wrong.

Others found also helpful: