Export (0) Print
Expand All

CrawledProperty class

Represents a crawled property in the SharePoint Enterprise Search metadata property schema.

System.Object
  Microsoft.Office.Server.Search.Administration.CrawledProperty

Namespace:  Microsoft.Office.Server.Search.Administration
Assembly:  Microsoft.Office.Server.Search (in Microsoft.Office.Server.Search.dll)

[SharePointPermissionAttribute(SecurityAction.LinkDemand, ObjectModel = true)]
public sealed class CrawledProperty

Crawled properties are the set of properties discovered by the SharePoint Enterprise Search index service component when crawling content. For more information about crawled properties, see Managing Metadata.

Crawled properties are grouped by category, based on the protocol handler that is used. Use the GetAllCrawledProperties method of the Category class to get the collection of CrawledProperty objects representing the crawled properties for a specific category.

Crawled properties are mapped to managed properties to make them available for the SharePoint Enterprise Search user experience. Use the GetMappedCrawledProperties() method of the ManagedProperty class to get the collection of CrawledProperty objects that represent the crawled properties mapped to a specific managed property.

The following code example writes out a list of crawled properties, which are mapped to a specific managed property, to the console window. For a complete, step-by-step walkthrough of this example code, see How to: Retrieve the Crawled Properties Mapped to a Managed Property.

Prerequisites

Ensure a Shared Services Provider is already created.

Project References

Add the following project references in your console application code project before running this example:

  • Microsoft.SharePoint

  • Microsoft.Office.Server

  • Microsoft.Office.Server.Search

using System;
using System.Collections;
using System.Text;
using Microsoft.Office.Server.Search.Administration;
using Microsoft.SharePoint;

namespace CrawledPropertiesSample
{
    class Program
    {
        static void Main(string[] args)
        {
            try
            {
                // Replace <SiteName> with the name of a site that uses the Shared Services Provider.
                string strURL = "http://<SiteName>";
                Schema sspSchema = new Schema(SearchContext.GetContext(new SPSite(strURL)));
                ManagedPropertyCollection props = sspSchema.AllManagedProperties;
                // Replace ManagedPropertyName with the name of a managed property.
                ManagedProperty mProp = props["<ManagedPropertyName>"];
                foreach (CrawledProperty cProp in mProp.GetMappedCrawledProperties(mProp.GetMappings().Count))
                {
                      Console.WriteLine(cProp.Name);
                      Console.WriteLine(cProp.Propset);
                 }
                 return;
            }
            catch(Exception ex)
            {
                Console.WriteLine(ex.ToString());
            }
        }
    }
}

Any public static (Shared in Visual Basic) members of this type are thread safe. Any instance members are not guaranteed to be thread safe.
Show:
© 2014 Microsoft