Working with Search Scopes

Working with Search Scopes

SharePoint 2007

In Microsoft Office SharePoint Portal Server 2003, search scopes were based on content sources and were tied to crawling. Content could be in only one scope at a time. In Microsoft Office SharePoint Server 2007, search scopes are expanded to represent a collection of items based on a common element among the items within that scope. For example, in addition to a search scope that represents content from a particular content source ("Portal Content"), it is now possible to define search scopes such as "All documents authored by ****" or "All documents related to Marketing". Scopes are no longer tied to content crawls, so when you create a scope, you do not have to wait for a recrawl of the content before the items in that scope are available for Search.

There are two types of search scopes: basic and compound.

Basic Scopes

Basic scopes are generated automatically from the scope plug-in when content is indexed by the crawler, and are based on specific properties of the content being indexed.

"All items authored by <specific author name>" is an example of a basic scope.

By default, the scope plug-in creates scopes for the following:

  • Display URL

  • Site (domain, subdomain, host name)

  • Author

  • All content (used to include all content)

  • Global query exclusions (used to exclude content)

Compound Scopes

Compound scopes are Boolean combinations of basic scopes. They can be grouped together and ordered within scope groups.

Search Scope Object Model

You can find the classes for managing search scopes in the Microsoft.Office.Server.Search.Administration namespace, located in Microsoft.Office.Server.Search.dll.

Following is a diagram of the Search Scopes object model.

Search Scopes object model
Search Scopes object model

For management of the overall scope system, you use the Scopes class. Table 1 describes the methods available in this class.

Table 1. Scopes class methods
Name Description


Retrieves a specified scope display group for a given site.


Retrieves the scope display groups for the specified site.


Retrieves the specified scope for a given site.


Retrieves the scopes for the specified site.


Starts the scope compilation.


Stops the scope compilation.


Updates any changes made to this object.

The ScopeCollection class is the collection object for scopes.

Individual scopes are represented by the Scope class. Table 2 describes the Scope class properties.

Table 2. Scope class properties
Name Description


Specifies a different results page for searching this scope.


The compilation state for the scope. Possible values are:

  • Compiled

  • Empty

  • Invalid

  • NeedsCompile

  • NeedsRecompile

  • QueryExpanded


The type of compilation for the scope. Possible values are:

  • AlwaysCompile

  • ConditionalCompile


Description of the scope.


The scope name.


Site that the scope belongs to.

The Rules property of the Scope class contains a ScopeRuleCollection object, which is the class that contains the set of rules, each as a ScopeRule object. These are applied to include or exclude content from that scope. The ScopeRule class is the base class for these rules. Three classes inherit from ScopeRule, as described in Table 3.

Table 3. ScopeRule derived classes
Name Description


Scope rule that includes all content in the search index. The FilterBehavior method is set to "Include" and cannot be changed.


Scope rule applied to items based on the display URL, and matched on either the folder, host name, or domain/subdomain of the URL.


Scope rule applied to items based on a property value comparison.

To manage the display of the scopes, use the ScopeDisplayGroup class. The ScopeDisplayGroupCollection class contains all of the display groups and is used to manage the display groups for the Search system.

Community Additions

© 2015 Microsoft