In an earlier post here we have seen how we can set Property Bag values in Modern SharePoint sites. One of the major reasons for setting Property Bag values in SharePoint sites is to make the SharePoint sites searchable based on custom metadata.
However, property bag values are not crawled by the SharePoint Online Search index directly. To make a property bag value searchable, we must explicit set the property bag values to be indexed by the Search crawler. To do this, we simply set the Property bag values to indexed using the SharePoint PnP PowerShell.
|Set-SPOSite "[siteurl]" -DenyAddAndCustomizePages 0|
|Set-PnPPropertyBagValue -Key "[propertyName]" -Value "[propertyValue]" -Indexed|
|Set-SPOSite "[siteurl]" -DenyAddAndCustomizePages 1|
The “-Indexed” attribute of the Set-PnPPropertyBagValue cmdlet makes an entry in a hidden system property bag value vti_indexedpropertykeys which then makes these property bag values searchable. A screenshot of the result is below.
After performing the above, we flag the site to be reindexed so that the SharePoint search crawler will pick up the new Property Bag values in the next crawl. This can be done from “Site Settings -> Search and offline availability” (in the Search group), then click the button “Reindex site” (screenshot below).
Note: Since SharePoint Online is a massive SaaS system, it can take up to 24 hours for the crawler to pick up this property. Unfortunately, there’s no workaround for this delay, you simply must be patient.
In the above post we saw how we can enable Property Bag values to be searchable.