Example of using CSOM to trigger a search index on a document library

2 months ago

By Eric Gregorich

You can trigger a search reindex in a SharePoint Online document library using CSOM.

// Reindex the library so it picks up the changes in search 
if (libraryHasCalculatedColumn) 
    context.Load(library.RootFolder.Properties, r => r["vti_searchversion"]); 
    var searchVersion = Int32.Parse(library.RootFolder.Properties["vti_searchversion"].ToString()); 
    library.RootFolder.Properties["vti_searchversion"] = searchVersion + 1; 

Spread the word

Keep reading