Schema Class
Assembly: Microsoft.Office.Server.Search (in microsoft.office.server.search.dll)
The Schema class is the entry point for managing the Enterprise Search metadata schema for a Shared Service Provider's search service. To use the Schema object, you must do the following:
Add references to your application for the following dlls:
Microsoft.SharePoint.dll
Microsoft.Office.Server.dll
Microsoft.Office.Server.Search.dll
Specify the Shared Service Provider for the search service using the SearchContext object. For more information about ways to retrieve the search context, see How to: Return the Search Context for the Search Service Provider.
The following topics contain code samples demonstrating how to use the Schema object model to perform various metadata management tasks programmatically:
How to: Retrieve the Managed Properties for a Shared Services Provider
How to: Create a Managed Property
How to: Delete a Managed Property
How to: Retrieve the Crawled Properties for a Category in the Search Schema
How to: Retrieve the Crawled Properties Mapped to a Managed Property
The following code example writes out the full list of managed properties to the console window. For a complete, step-by-step walkthrough of this sample code, see How to: Retrieve the Managed Properties for a Shared Services Provider.
Prerequisites
Ensure a Shared Service Provider is already created.
Project References
Add the following Project References in your console application code project before running this sample:
Microsoft.SharePoint
Microsoft.Office.Server
Microsoft.Office.Server.Search
using System; using System; using System.Collections.Generic; using System.Text; using Microsoft.Office.Server.Search.Administration; using Microsoft.SharePoint; namespace ManagedPropertiesSample { class Program { static void Main(string[] args) { try { //Replace <SiteName> with the name of a site using the Shared Service Provider. string strURL = "http://<SiteName>"; Schema sspSchema = new Schema(SearchContext.GetContext(new SPSite(strURL))); ManagedPropertyCollection properties = sspSchema.AllManagedProperties; foreach (ManagedProperty property in properties) { Console.WriteLine(property.Name); } } catch(Exception ex) { Console.WriteLine(ex.ToString()); } } } }