Want to Rebuild indexes on publish programmatically something like below in Sitecore 9.1,
We were using Sitecore 7.5 and for index update using below mentioned code. Now we have upgraded to Sitecore 9.1 and this code is not supporting. We searched for documentation but didn't found any. Can you please provide alternative for this or any solution for this ?
public static void UpdateAllIndexes()
var db = Sitecore.Configuration.Factory.GetDatabase(EnvironmentContext.ContentDatabase);
if (db == null)
Please suggest an alternative for above issue .