Content Classes in SharePoint Search

Content Classes make it possible to get the specific types of content you want returned from a search request.  This can be from an interactive search executed by a user or by an automatic search configured to supply content across a SharePoint farm. 

Here is a list of Content Classes as well as an overview on how specific list, library, and item classes can be structured.

  • SPSPeople – Will return only user profile objects.
  • STS_Site – Will return only site collections
  • STS_Web – Will return only sub-sites (aka webs)
  • STS_list_doccumentlibrary – Will return all document libraries.  The “documentlibrary” part can be substituted with any other standard template name or the template id for use with custom lists. 
  • STS_listitem_documentlibrary – will return all of the items from the document libraries.  Like the proceeding item “documentlibrary” specification can be replaced with the appropriate template name or id.

Custom Search Scopes

For interactive searches, performed by your users, you can define custom search scopes to narrow the search results.  In addition to specifying rules like the Content Source, you can specify the specific Content Class. 

In some cases users do not want to see Sites and Webs show up in the search results for a particular section of a site.  You can specify a rule that excludes these objects from the results for that scope.

In other cases where perhaps there are 100s of sites, a search scope that only returns Sites and Webs may be desirable. 

Using Search to Display Content

In addition to interactive searches, the search system can also be used to provide content as part of normal site configuration. 

Presentation Methods

The returned content can be configured to be displayed Core Results or People Core Results web parts.  These web parts provide the ability to configure the search query information as well as support customizing the display through XSLT.

The query can also be executed and the results displayed in a custom web part by calling either the Search API or the SPSearch.asmx web service.  This gives the developer the ability to show the content in whatever context it is required including for custom navigation or content outside of the normal page body.

Content Aggregation

It can be used to aggregate content across site collections and applications.  This is one potential method to grab news and announcements across a large site in an efficient manner.  It can also be used to pull navigation elements across site collections (with security trimming) as mentioned above.

Working With Large Lists and Libraries

It can provide an effective means to interact with a very large list or library.  Since it is relying on the index, not real-time calls against the list, performance tends to be much better.  

Department, Team, or other People

A lot of people would like a dynamic way to display the members of a department, team, or maybe cross-functional group.  Static contact lists have been around since the beginning of SharePoint, but it can be a maintenance nightmare.  By specifying the SPSPeople content class along with a query against the user’s profiles you can retrieve a list that maintains itself as the user profiles are managed.

Summary

Using the search system can provide a consistent, highly scalable way to access content throughout the farm.  Specifying the Content Class provides a means to retrieve the specific type of content you are looking for.  The resulting features are very powerful and should be in every developer and customizer’s tool bag.

Related Articles

Tags:

Leave a Comment