Note
Access to this page requires authorization. You can try signing in or changing directories.
Access to this page requires authorization. You can try changing directories.
Provides access to the property metadata management system for Enterprise Search.
Inheritance Hierarchy
System.Object
Microsoft.Office.Server.Search.Administration.Schema
Namespace: Microsoft.Office.Server.Search.Administration
Assembly: Microsoft.Office.Server.Search (in Microsoft.Office.Server.Search.dll)
Syntax
'Declaration
<SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel := True)> _
Public NotInheritable Class Schema
'Usage
Dim instance As Schema
[SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel = true)]
public sealed class Schema
Remarks
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
How to: Map a Crawled Property to a Managed Property
Examples
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());
}
}
}
}
Thread Safety
Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.