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.
Applies to: 2007 Microsoft Office System, Microsoft Office SharePoint Server 2007
Patrick Tisseghem, U2U
April 2007
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. 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.
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
Figure 1. Classes used to programmatically access and maintain the managed properties |
Length: 15:02 | Size: 14.5 MB | Type: WMV file |