I recently got a question regarding the ability to filter out folders from search results (but to still search inside those folders for documents) in MOSS 2007.
It’s pretty simple. You’ll need to create a scope with two exclusion rules, assuming you’re crawling both file shares and SharePoint sites (one for file share folders and one for document library folders):
1) Go into Search Settings -> Metadata Property Mappings
a. Scroll to the “IsDocument” property and select “Edit/Map Property” from the drop-down menu; check “Allow this property to be used in scopes”
b. Do the same with the “ContentType” property
2) Create a new scope (called “NoFolders” or whatever) and add three rules:
a. Content Source = All Content
b. IsDocument=0 (make that one an exclusion rule) – this is for file share folders
c. ContentType=Folder (also an exclusion rule) – this is for sharepoint document library folders
3) Run a scope update to refresh the scope contents
4) Do a search on a term that returns a folder (Say, “office”); then try another, specifying the scope like this – “office scope:nofolders” (this search should not return folders)
5) If you want that new scope to be the default (so users don’t have to specify the scope), you can set the scope property of the search results web part on the results.aspx page to use that new scope (or you can create a new tab on the search center page)
Some Other good Practice while Configuring Search
– Using FreeText and Contains makes handling wildcards and phrases very easy when building your SQL query string.
– You can stop Lists appearing in results by adding a search scope rule to exclude items where contentclass = STS_List_GenericList.
- Crawl rule to exclude all form: http://*/Pages/Forms/*
- Crawl rule to exclude layout: http://*/_layouts/*
- Crawl rule to exclude Style library: http://*/Style Library/Forms/*
- Crawl rule to exclude list: http://*/lists/*
- Crawl rule to exclude list: http://*/forms/*