Latest version of the script can be found at https://github.com/wobba/SPO-Trigger-Reindex
In SharePoint Online you cannot trigger a full re-index of all your data as you can on-premises via the Content Sources on your Search Service Application.
And this might be something you would like to do, especially if you start mapping crawled properties to new managed properties. A full list of scenario’s which require a full re-index is available at TechNet.
The only option provided in SPO is to via the settings pages on a site or a list/library, trigger a re-index as outlined in the SPO documentation.
But fortunately this is not entirely true, as you via CSOM can manipulate a site’s property bag and set or change the value of vti_searchversion which is what triggers a re-index of this site. The same property applies to a list/library.
The below script uses the SharePoint Online Management cmdlets to iterate all the site collections, and SharePoint CSOM to iterate the sites within each site collection. For each site it will update vti_searchversion, which will trigger the site to be picked up for re-indexing on the next crawl cycle.