You can find more about this on those blogs:
- http://blogs.msdn.com/b/armenk/archive/2013/02/12/how-to-force-whole-list-or-library-to-be-re-crawled-by-search.aspx
- http://www.learningsharepoint.com/2012/12/17/the-new-reindex-list-and-reindex-document-library-option-in-sharepoint-2013/
Important: It does not work in SharePoint 2010!
It is also possible to do it for whole web. Thanks to this all items in all lists will be re-crawled.
I would like to show you how to do it using API.
When using API you can use it on any type of list. It also works for non-document library items, like tasks.
Re-crawl Web
void Main() { using (SPSite site = new SPSite("http://demosvr1/web1/")) using (SPWeb web = site.OpenWeb()) { object versionObj = web.AllProperties["vti_searchversion"]; int version = ((versionObj is int) ? ((int) versionObj) : 0); web.SetProperty("vti_searchversion", (version + 1)); web.Update(); } }
Re-crawl list
void Main() { using (SPSite site = new SPSite("http://demosvr1/web1/")) using (SPWeb web = site.OpenWeb()) { SPList docList = web.Lists["Documents"];
object versionObj = docList.RootFolder.Properties["vti_searchversion"];
int version = ((versionObj is int) ? ((int) versionObj) : 0);
docList.RootFolder.SetProperty("vti_searchversion", (version + 1));
docList.Update();
} }
No comments:
Post a Comment