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.

3 comments:

Unknown said...

Setting the list's NoCrawl to false/true does not change the radio button in the GUI.
Any idea why this is happening?

Douglas Leung said...

Have you run list.Update() ?
It works for me.

Unknown said...

Hi Douglas,

I need to set the nocrwal property by using webservices(Not Object model).I have spent lods of time in that but of no use.

please let me know hoe do do this