Creating and Exposing Managed Properties in the Advanced Search Page of SharePoint Server Enterprise Search

Summary:  Learn how to create and expose managed properties in the Advanced Search page of Microsoft Office SharePoint Server Enterprise Search.

Office Visual How To

Applies to:  2007 Microsoft Office System, Microsoft Office SharePoint Server 2007

Patrick Tisseghem, U2U

April 2007

Overview

Lists and document libraries in SharePoint sites typically have extra columns defined for them. This custom metadata is collected by the crawler when it indexes the contents of these containers. Administrators can expose this custom metadata to the users who perform search queries in the Search Center. The Advanced Search page has a property picker that can be populated with managed properties. This article explains and illustrates how to expose managed properties to the user, and also explains how developers can programmatically create managed properties.

Code It

You can add managed properties to the property picker in the Advanced Search page by modifying the XML attached to the Advanced Search Box for the properties. A PropertyDef element registers the managed property, and a PropertyRef element as a child of the ResultType element is used for the visualization.

XML for Adding a Managed Property to the Property Picker

References and Namespaces for Programmatically Working with Managed Properties

You must run the sample code on a server running SharePoint Server 2007. The sample code requires references to the Microsoft.SharePoint.dll, the Microsoft.Office.Server.dll, the Microsoft.Office.Server.Search.dll and the System.Web.dll. The following namespaces are used:

Connecting to Shared Services Provider and the Search Context

Before getting access to the managed properties programmatically, you need to understand the reference to the context of the Shared Services Provider and the Search Service. The following example illustrates these concepts. The example assumes that the name of the Shared Services Provider is "SharedServices1".

Retrieving the List of Managed Properties

Your entry point in the search namespace to work with managed properties is an instance of the Schema class. This class exposes the AllManagedProperties property, which can be used in a loop for displaying all of the individual ManagedProperty instances. A call to the GetMappings method retrieves per managed property the crawled properties that are mapped to it.

Retrieving the List of Crawled Properties

You can use the method QueryCrawledProperties, which is exposed by the Schema class, to retrieve all of the crawled properties. Since this can be a huge list, there are parameters available that filter and restrict the amount of properties that QueryCrawledProperties retrieves.

Creating a Managed Property

You can create a managed property by calling the Create method of the ManagedPropertyCollection. Arguments are the name of the managed property and the type of the information that it will store.

Mapping Crawled Properties to a Managed Property

An instance of the class MappingCollection can be populated with Mapping objects. Each one represents one mapping of a crawled property with a managed property.

Read It

When content in a SharePoint site gets crawled, custom metadata is collected and stored by the crawler in the Property Store (one of the databases under the control of the Shared Services Provider). In the administration site of the Shared Services Provider, administrators can map one or more of these crawled properties to a managed property. A managed property can be exposed in the property picker of the Advanced Search page and also in the page where you define shared search scopes.

To create a managed property

  1. In the Search Settings of the Shared Services Provider administration site, click on Metadata Property Mappings

  2. The Quick Launch displays a link to the page that displays the list of managed properties as well as a link to the page that displays the list of crawled properties.

  3. In the page that shows the managed properties, click New Managed Property to create a new one. You can set a title (no spaces allowed), a description, and the type of the information stored in the property.

  4. Crawled properties can be mapped by opening the Crawled Property Selection dialog.

  5. The option to use the managed property in the definition of a search scope can be activated.

Figure 1. Classes used to programmatically access and maintain the managed properties

Classes to access and maintain managed properties
See It MOSS2007 Creating Exposing Managed splash

Watch the Video

Length: 15:02 | Size: 14.5 MB | Type: WMV file

Explore It