What are Scopes?
If you have done any configuration of SharePoint search prior to SP2013 then you are likely familiar with search scopes. Scopes are pre-defined rules that allow users to refine a search by a URL, property, or content source.
A combination of rules can be strung together in order to included and exclude necessary parameters. Scopes allow users to potentially skip several clicks that would be necessary to refiner searches through faceted search or advanced queries. At the most basic function they act as query rules.
Figure- 1 SharePoint 2010 Scope Picker
Scopes can also allow a user to be redirected
to a context-sensitive search center. Each selected scope can send the query to a pre-defined search center. For example, in the screenshot above, Payroll and Employee Records may direct to a search center with web parts integrating active directory and HR system data. The Tax Forms scope may send employees to a search based application with personal earnings reports, a best bet 1099, and web part displaying tax tips.Create or Edit Scopes in the Search Service Application
In MOSS 2007 and SharePoint 2010 scopes are enabled and configured in a similar way. You first need to define a scope. Scopes can be defined at either the Central Administration level or Site Collection level. Each scope can be individually toggled for display on advanced search or the scope picker so my advice is to configure through Central Administration unless you have a good reason otherwise. This just helps to keep track of configuration down the road. To do this you visit the Search Service Application in Central Administration. Follow the “Scopes” link on the left hand navigation and you can add, modify, or delete scopes.
To add a scope,
just click the “add scope” button. Give the new scope and name and specify if you would like the scope to redirect the user to the default search center or a different search page. This option to send users to a specialized page based on scopes is important as your environment evolves to context sensitive search experiences or search based applications. space
Figure – 2 Scopes in SP2010 Search Service Application
Once the scope is created
, you can click it and access it to define query rules that are applied when a user selects the corresponding scope. Rule types can include URLs, properties, or content sources. Only metadata properties that have been set up for use in scopes will be available at the point of configuration. Content sources must be set up in advance as well.
You can also set whether the scope’s behavior will include any search results that matching the rule, require every item to match the rule, or exclude results matching the rule. The combination of a target search page, rule types, and rule behavior open a wide range of uses for scopes that will change between SharePoint sites.
New scopes will not be available for 14 minutes after creation. You can force a scope to be available quicker by navigating to the top of the SSA configuration in Administration and then selecting for new scopes to be calculated under System Status as shown below.
Figure – 3 Manually Update SP2010 Scopes
Adding Scopes to Advanced Search and Search Dropdown Display Groups
Now that new scopes have been configured and made available through Central Administration, you need to display them to your users. On your SharePoint front end, go to Site Actions – Site Settings. Scopes can only be configured at the Site Collection level so if you are on a sub site navigate up to top level site settings through the link shown below.
Figure – 4 Search Scopes Configuration Link in SP2010 Site Collection Administration
You will now find an abundance of additional administration features. Follow the Search Scopes link and you will see a list of all scopes shared with your site collection. By default they are split into three groups which include Search Dropdown, Advanced Search, and Unused. Scopes listed under Search dropdown will, and the title suggests, appear with the search box in the scopes dropdown. Scopes in the Advanced Search display group can be available on advanced search pages. Every scope can belong to more than one Display Group.
To add, remove, or change the order of scopes within a display group simply click the Search Dropdown or Advanced Search link. On the page shown below you will find a list of all available scopes. Checkmarks indicate the scopes that are enabled for the display group. On this page you can also reorder the scopes order or set change the default scope. space
Figure – 5 Edit Advanced Search Scopes Display Group
Display the Scopes Dropdown on SharePoint Sites
The final step is to enable the scopes feature on the advanced search page or scopes dropdown. To enable the scopes dropdown, navigate to Site Actions – Site Settings – Search Settings. This link is directly above the search scopes link shown in Figure 4. Just like adding scopes do a display group, you must be at the Site Collection Administration level to configure this feature.
On the Search Setting page there are a few important options that change the user experience. To use custom scopes, you must enter the URL for a search center where the query will be sent. Once a user executes a query with a custom scope they will be automatically navigated to the search center you define. Through this mechanism you can have one search center for contextual scopes and a different default search center for custom scopes. Keep in mind that All Sites and People are considered “custom” scopes. space
Figure – 6 SP2010 Scope Dropdown Mode
Next you need to select one of seven options for how the scopes operate. The most basic option with scopes is “Show Scopes Dropdown”. Other options include whether the scope dropdown is displayed, the target result page, and whether contextual scopes are available. Contextual scopes are those such as “This Site: [Site Name]” or “This List: [List Name]” and are managed automatically by SharePoint.
The final setting is to enter the URL for a search center used for contextual scopes. This can be a secondary search result page or the same search center used for custom scopes. Once you have applied the desired configuration, just click “OK” and you are finally set.
At this point you have enabled scopes on the small search box located in the top right of each SharePoint page. If you selected to show the scoped dropdown then you will now find it on any site within your site collection as shown below.
Figure – 7 SP2010 Scope Dropdown with Contextual SearchDisplay the Scopes Dropdown on the Search Center
To enable the scopes dropdown on a search or search results page, you still need to enable the feature on the search box web part. First, navigate to the search or search results page where you want to display the scope dropdown. Next, go to Site Actions – Edit Page and then edit the search box web part. The first expandable configuration window is for the Scopes Dropdown. Select the desired dropdown mode just like on the Search Setting page. Apply the change and check in your page. If you selected to show the scopes dropdown then the search page will appear like the example in Figure 1.
Figure – 8 Editing the Search Box Web PartDisplay Scopes on the Advanced Search Page
The final step to displaying scopes is to make them available on the Advanced Search Page. This is done almost exactly like enabling the scopes dropdown on a search results page. Navigate to the Advanced Search Page, go to Site Actions – Edit Page and then edit the Advanced Search Box web part. The second expandable configuration window is for scopes. Here you can enable the scope picker, language picker, and result type picker. On the Advanced Search page there are not a variety of scope dropdown modes as a series of check boxes are either enabled or disabled. Select to show the scope picker, apply the change, and check in your page. The end result is a display like the one below.
Figure – 9 Scopes on the Advanced Search PageGotchas!There are a few tricks to keep in mind when working with scopes in SP2010.
If search works fine but contextual scopes do not return results then check your Alternative Access Mapping (AAM). The host header that is specified in your default zone needs to match the URL in your search content source. This should only be a problem if you have been tinkering with AAM.
Scopes can only be configured at the site collection level or above in SP2010’s GUI. You cannot display a set of custom scopes for sub site A and a different set of scopes for sub site B if they are in the same site collection. With a healthy amount of Visual Studio and SharePoint Designer experience this functionality is possible but difficult. Ontolica Search does allow for site/sub site level control of search scopes.