Showing posts with label Search. Show all posts
Showing posts with label Search. Show all posts

Tuesday, July 15, 2008

Microsoft SharePoint 2007 - Including/Excluding a list in the Search Index

Have the search results in your WSS/MOSS environment been ugly with all that list data? Did you want the content source to include content excluding list data?

In SharePoint, the content in each list can be configured to be included or excluded from being indexed in search crawls.

Through the SharePoint UI, this option is called "Allow items from this list to appear in search results?" and is located in the Advanced List Settings:



Through the SharePoint API, this option is exposed as a property called "NoCrawl" (for the list named "Hidden From Search List"):


SPSite site = new SPSite("http://siteurl");
SPWeb web = site.RootWeb;
SPList list = web.Lists["Hidden From Search List"];
list.NoCrawl = false;
list.Update();


After this property has been updated, the next time SharePoint Search crawls, it would skip indexing the list with a NoCrawl value of false.