Monday, April 15, 2013

SharePoint Search: IsDocument and contentclass properties

A common request, when you're setting up a Search Service Application, is trimming results to documents only. Usually, it's not added value to show lists, libraries, folders or sites as search result items (for refinement, it's a completely different story).

Throughout the years, I've seen people achieving this in multiple ways (most commonly excluding *.aspx using crawl rules), but the right way of doing it is creating a scope and using either the IsDocument or contentclass properties.
(...)


To set up a scope using the IsDocument, in SharePoint 2010:
  1. Open Central Administration
  2. Go to Manage service applications, in the Application Management section
  3. Go to your Search Service Application
  4. Go to Scopes, in the Queries and Results section
  5. Create a new scope
  6. Configure the scope details appropriately (not relevant to our scenario) and click OK
  7. Back to the Scopes page, hover over the newly created scope and in the contextual menu select Edit Properties and Rules
  8. The Scope Rule Type will be Property Query
  9. In the Property Query, select IsDocument and value 1
  10. The Behavior is Require
  11. Click OK and the configuration is done!
An alternative configuration is using the contentclass property and value STS_ListItem_DocumentLibrary. The main difference is that using the contentclass property, you have the ability to select the type of results you want. You can check the list of values the contentclass property uses, in this link (from the 2007 version, but still applicable). In the example above, only document library items would be returned.

With the IsDocument property, the definition is broader. For instance, pages and images will be included. You pretty much letting SharePoint decide for you, on what is or isn't considered a document.

Both option are suitable and the choice will ultimately depend on the specific requirement you have, there's no right or wrong.

No comments:

Post a Comment