The Latest Time Saving Tips for Your SharePoint Deployment

Corey Roth

Subscribe to Corey Roth: eMailAlertsEmail Alerts
Get Corey Roth via: homepageHomepage mobileMobile rssRSS facebookFacebook twitterTwitter linkedinLinkedIn

Related Topics: Microsoft Developer

Blog Feed Post

Excluding Folders from Search Results

You have a set of search results, and the user just wants to see the documents, not the folder that contains the documents

I see this topic come up quite a bit.  You have a set of search results, and the user just wants to see the documents, not the folder that contains the documents.  Consider the following example, when I query for accounting documents below.


As you can see in the results above, the first item returned is the folder named Accounting which contains the documents listed after it.  Many times, people do not want this showing up in the results, so we need to come up with a way to remove it.  The easiest way of course is to use the IsDocument keyword and pass it a value of 1.  This will give you results like the ones below.


As you can see, this works great, but you don’t exactly want to have to explain to the user how to type in IsDocument:1 into the search box.  However, it is quite easy to include this if you are building your own advanced search control.  One way to handle this is to create a custom scope that just returns documents.  This is quite easy to do but there are a few steps.  The first thing we need to do is allow the IsDocument managed property to be used in scope rules.  To do this, go to Search Administration –> Metadata Properties and then find IsDocument in the list.  Check the Allow this property to be used in scopes checkbox and hit ok.


After making changes to any property in search, you of course need to perform a full crawl.  This could take minutes or days depending on the size of your search index.  Once you are done, go to the Scopes page and create a new scope.  For the purpose of my example today, I’ll just call mine Documents.  After you create the new scope, you need to add a new rule.  Choose Property Query and then select IsDocument from the list.  Enter a value of 1 and choose Require.  Now whenever you query against this scope only documents will be returned.  Perform a scope update when you are finished or simply wait for the timer job to update it whenever it is scheduled.

Read the original blog entry...

More Stories By Corey Roth

Corey Roth, a SharePoint Server MVP, is an independent consultant specializing in Cloud technologies such as Azure and Office 365. He also specializes in mobile development. Corey serves as the product manager for two cloud-first mobile app platforms: BrewZap and HappenZap.