June 2009 - Posts

It is evident that SharePoint can index content in web sites, file shares, exchange public folders, or any other content that has a URL. However, many users like to execute a search which is restricted to a specific type of content such as Tasks, Announcements, Events, Documents, Blogs etc or a content source such as a document workspace or a team site or a file share etc. On a similar note I would like to quote what one of our customers who was evaluating our search product Longitude for SharePoint asked for.

"We are most concerned with documents and to us, most of the other items that come up that may contain the search string are clutter and it would be nice to easily filter them out"

The customer basically wanted a provision to narrow down search to documents only and was not interested in the announcements, events, and wiki pages etc that came up in the resutls.Typically when the requirement is about being able to execute a search restricted to a content type or a content source, SharePoint Search scope is the way to go.

In this article, we will go through all those configurations required to create a search scope that will be dedicated to return only documents. Before we start with the configurations required, let's take a look at the basics of SharePoint search scope.

In an enterprise, gigs and terabytes of data is crawled from various content sources on a regular basis. The crawls create a single content index representing all the content sources. SharePoint provides search scopes as a way to filter the content index to define a subset of it. By effectively defining a section of the content index a head of the query time, search scopes facilitate to limit the results that are returned from the index. Search scopes are pre-compiled and efficient.

SharePoint has two types of search scopes.

The Contextual scopes are created automatically based on the context of the site area user is currently working on such as a web or a list etc. In a SharePoint site, these scopes read like "this site", "this list" etc.

The Custom Scopes are the ones that an administrator can create to target a specific type of content. Two types of custom scopes can be created:

  • SSP Level Scopes are global and shared across all the site collections that are associated with the SSP. The SSP level scopes are managed at the SSP level by a farm administrator.
  • Site collection level scopes are local to a site collection and are managed by the site collection administrator.

Create a scope to return only documents in search

In the steps outlined below, we will be creating a SSP level scope called "All Documents" and add a rule to include only documents.

Step1: Create a all documents scope

  • Browse to the central administration site and Click on the SSP.
  • Click on search settings and then Click on view Scopes.
  • Click on new scope link.
  • Enter title as "All Documents" and leave other details blank and Click OK.

Step2: Allow the "IsDocument" property to be used in scopes

IsDocument is a managed property provided by SharePoint and is true for all documents only. Therefore, before adding a scope rule to the scope "All Documents", we must ensure that this property can be used in scope. Follow the steps to allow the property to be used in scopes.

  • Browse to the central administration site.
  • Click on the Shared Service Provider (SSP).
  • Click on Search settings
  • Click on metadata property mappings.
  • Find the managed property IsDocument and set "Use in Scope" property to true and Click Ok.

Step3: Add scope rule

  • Browse to the central administration site.
  • Click on the Shared Service Provider (SSP) for the site.
  • Click on Search settings
  • Click on View Scopes.
  • Click on Edit Properties and rules for the scope "All Documents".
  • Click on New Rule.
  • Add a property query rule where the property IsDocument=1 and set the scope behavior to require and click OK.

Step4: Add the scope to a scope display group

A scope display group is used to organize a list of scopes. The scope display group is then assigned to a search box to be able to search on those scopes. To add the scope "All Documents" to a scope display group, follow the steps below:

  • Browse to the site collection for your search center (This is the site collection which has your search page).
  • Select Site actions>Site settings>Search scopes. You will notice that the scope "All Documents" has no scope display group assigned at this time. We can either create a new display group and add or add it to an existing group.
  • Click on the scope display group "Search Dropdown" and Select the scope "All Documents".

Step5: Using the scope display group for a search box web part

The scope display group "Search Dropdown" has our scope included in it. In this step, we will ensure that our search box webpart uses this scope display group.

  • Browse to the search page and select site actions>edit page.
  • Select edit>modify shared webpart on the search box web part.
  • On the properties pane, expand the section miscellaneous and check the property value for the property scope display group and make sure that it is "Search Dropdown" as selected at #Step4.

Step6: Update the scope

Unless the scope is updated, it will not appear on the scopes dropdown of the search box webpart. To update the scope, follow the steps below.

  • Browse to the central administration site and Click the SSP for the site collection.
  • Click on search settings and then Click on Start update now.

We are done. The scope "All Documents" must be available on the scopes dropdown of the search box webpart. If it does not, you would want to make sure that show scope dropdown option is selected for the webpart.

Finally, some frequently asked business requirements questions from our customers where search scopes have been used.

1) I have a content source (cs1) which is an archive of past projects and is static and I have another content source (cs2) which has all active projects with dynamic content. I crawl cs1 once a week and crawl cs2 once a day. However, I want to be able to search results from both content sources at one place in a Global Search Center.

  • Create a scope say "Global Scope".
  • Add an include rule by selecting cs1 as the content source.
  • Add another include rule by selecting cs2 as the content source.
  • Use the scope "Global Scope" in your Global Search Center to be able to view results from both the site collections at one place.

2) How do I get only PDF documents in my search results?

  • Create a scope say "PDF Documents"
  • Add a property query based rule where FileExtension is equal to pdf.
  • Set the scope rule behavior to include.
  • Update the scopes.
  • Search using the scope "PDF Documents".

3) I want to search on only those documents that have been tagged as "Legal Documents".

This requirement has got two aspects of it:

  • Results must be documents not a blog posts or wiki pages or a list item etc
  • Results must have only those documents which have been tagged as Legal documents.

Here you will have to create a document with two scope rules. The first would be to include all the documents from the content index and the second would be to ensure that only Legal documents are included. Assuming that you have a managed property called "Tag" mapped to the column that stores the tags for the documents, follow the steps below to create a scope to search against.

  • Create a scope say "Legal Documents"
  • Add a property query based rule where IsDocument is equal to 1 and Set the scope rule behavior to include.
  • Add another property query based rule where Tag is equal to "Legal" and Set the scope rule behavior to require.
  • Update the scopes.
  • Search using the scope "Legal Documents".

4) I want to search on only those documents that have been tagged as "Legal Documents" and are not authored by Martin.

As opposed to the requirement #3, this one has got three aspects of it:

  • Results must be documents not a blog posts or wiki pages or a list item etc
  • Results must have only those documents which have been tagged as Legal documents.
  • Results must not have those documents which are authored by Martin.

In addition to the two rules as mentioned #3, we would also need a third rule to exclude those documents where Martin is the author. Therefore, assuming that you have a managed property called "Tag" mapped to the column that stores the tags for the documents, follow the steps below to create a scope to search against.

  • Create a scope say "Legal Documents"
  • Add a property query based rule where IsDocument is equal to 1 and Set the scope rule behavior to include.
  • Add another property query based rule where Tag is equal to "Legal" and Set the scope rule behavior to require.
  • Add another property query based rule where Author is equal to "Martin" and Set the scope rule behavior to exclude.
  • Update the scopes.
  • Search using the scope "Legal Documents".

5) I have many blog sites which are spread over different site collections. How do I have a search scope that returns only blogs related results.

This requirement is to include content specific i.e. blog related items in the search scope that can be search against. We must see if there is a property which represents a specific type of content. Fortunately, contentclass is one such property that distinguishes content from one another. Therefore follow the steps below to create a scope.

  • Create a scope say "Blogs"
  • Add a property query based rule where contentClass is equal to "sts_listitem_posts" and Set the scope rule behavior to include.
  • Add another property query based rule where contentClass is equal to "sts_listitem_comments" and Set the scope rule behavior to include.
  • Update the scopes.
  • Search using the scope "Blogs".

Note: Just like "sts_listitem_posts" and "sts_listitem_comments", there are other pre-defined values Sharepoint assigns to the property contentClass to represent different types of content. The table below has most of them.

STS_Document

STS_List_Comments

STS_List_300

STS_List_Contacts

STS_List_850

STS_List_DiscussionBoard

STS_List_Announcements

STS_List_DocumentLibrary

STS_List_Categories

STS_List_Events

STS_List_GenericList

STS_list_Links

STS_List_PictureLibrary

STS_List_Posts

STS_List_Tasks

STS_ListItem_300

STS_ListItem_850

STS_ListItem_Announcements

STS_ListItem_Categories

STS_ListItem_Comments

STS_ListItem_Contacts

STS_ListItem_DiscussionBoard

STS_ListItem_DocumentLibrary

STS_ListItem_Events

STS_ListItem_GenericList

STS_ListItem_Links

STS_ListItem_Posts

STS_Site

STS_Web

 

 

Del.icio.us | Digg It | Technorati | Blinklist | Furl | reddit | DotNetKicks

Sharepoint search scope is the way to go to realize the above requirement.In this article, we will go through all those configurations required to create a search scope that will be dedicated to return results from a file share only.

Before we start with the steps to create our scope for file share, let's take a look at different types of search scopes, scope rules and scope behavior.

Scope Types

SharePoint has two types of search scopes.

The Contextual scopes are created automatically based on the context of the site area user is currently working on such as a web or a list etc. These scopes let user search content from those specific areas only. In a SharePoint site, these scopes read like "this site", "this list" etc.

The Custom Scopes are the ones that an administrator can create to target a specific type of content. Two types of custom scopes can be created:

  • SSP Level Scopes are global and shared across all the site collections that are associated with the SSP. The SSP level scopes are managed at the SSP level by a farm administrator.
  • Site collection level scopes are local to a site collection and are managed by the site collection administrator.

Scope Rules

The custom scopes can be created based on the following types of scope rules.

Web Address -With web address you can limit the results to a certain web address only. Such as a document library or a list in sharepoint, a sharepoint subsite, a sharepoint site collection or a folder in a sharepoint document library etc.

Property Query applies restriction as a comparison of property to a value. Such as you can restrict results to  the documents where the property Author=Mark or exclude the documents where Author=Martin or require that all the documents in the results must be authored by John. How the scope rule should apply to a scope is defined by scope behavior and will be dealt in the section Scope behavior.

A content source that has already been created can be used to create a scope that includes all the items indexed by the content source.

By choosing All Content type scope, the scope will include all the items indexed by all the available content sources.

Scope Behavior

How a scope rule should be applied to the overall scope is defined by scope behavior. One of three behaviors can be applied to a scope rule.

Include - Any item that matches this rule will be included, unless the item is excluded by another rule. Select this option if you want the rule to be applied (if another rule precludes its inclusion, it won't be included). The include option is analogous to the logical operator AND.

Require - Every item in the scope must match this rule. Select this option if you want the rule to be applied regardless of other rules. The require option is analogous to the logical operator OR.

Exclude-Items matching this rule will be excluded from the scope. Select this option if you want items that match this rule to be excluded from the search scope.

Create a scope to return documents from a File Share?

We looked at what search scopes are and how are they applied to SharePoint content index, here we create a scope to search documents from a file share.

Step1: Create a content source to crawl your FileShare

  • Browse to the central administration site and Click the SSP for the site collection.
  • Click on search settings and then Content sources and crawl schedules.
  • Click on New Content Source link.
  • Enter a content source name and address url to the FileShare such as file://devserver/sampledocuments or file://devserver/sampledocuments
  • Click ok.

Step2: Create a scope based on the content source

  • Browse to the central administration site and Click the SSP for the site collection.
  • Click on search settings and then Click on view Scopes.
  • Click on new scope link.
  • Enter title as "FileShare" and leave other details blank and Click OK.
  • Click on Add Rules option for the scope "FileShare"
  • Select the content source created for the FileShare in step #1 and Click OK.

Step3: Add the scope to a scope display group

A scope display group is used to organize a list of scopes. The scope display group is then assigned to a search box to be able to search on those scopes. Lets add our scope "FileShare" to a scope display group.

  • Browse to the site collection for your search center (This is the site collection which has your search page).
  • Select Site actions>Site settings>Search scopes. You will notice that the scope "FileShare" has no scope display group assigned at this time. We can either create a new display group and add or add it to an existing group.
  • Click on the scope display group "Search Dropdown" and Select the scope "FileShare".

Step4: Using the scope display group for a search box web part

The scope display group "Search Dropdown" has our scope included in it. In this step, we will ensure that our search box webpart uses this scope display group.

  • Browse to the search page and select site actions>edit page.
  • Select edit>modify shared webpart on the search box web part.
  • On the properties pane, expand the section miscellaneous and check the property value for the property scope display group and make sure that it is "Search Dropdown" as selected at #Step2.

Step5: Updating the scope

Unless the scope is updated, it will not appear on the scopes dropdown of the search box webpart. To update the scope, follow the steps below.

  • Browse to the central administration site and Click the SSP for the site collection.
  • Click on search settings and then Click on Start update now.

That's it. The scope "FileShare" must be available on the scopes dropdown of the search box webpart. If it does not, you would want to make sure that show scope dropdown option is selected for the webpart.

Del.icio.us | Digg It | Technorati | Blinklist | Furl | reddit | DotNetKicks