Creating a Custom Indexing Connector

Applies to: SharePoint Server 2010

In this article
Coding the Assembly
Creating the BCS Model File
Deploying the Custom Indexing Connector

Microsoft SharePoint Server 2010 search uses Microsoft Business Connectivity Services (BCS) to crawl and index external data. If your external system is not directly supported by Business Connectivity Services, you can expose your external system via Business Connectivity Services by writing code to create a Web service, a .NET connectivity assembly, or a custom indexing connector. If the entity model in the external system is dynamic, has custom types, and is large-scale, you should consider creating a custom connector for that data source type. For more information, see Differences Between Using the .NET Assembly Connector and Writing a Custom Connector.

This topic describes the requirements for creating a custom indexing connector for SharePoint Server search, and addresses the following tasks:

  • Coding the assembly for the custom indexing connector

  • Creating the Business Connectivity Services model file

  • Deploying the custom indexing connector

Tip

For information about creating Web services and .NET connectivity assemblies for Business Connectivity Services, see Creating .NET Connectivity Assemblies and Web Services.

Coding the Assembly

You must do the following in the code you write for the custom indexing connector assembly:

  • Implement the required connector framework types.

  • Define the external content types.

  • Implement methods for SpecificFinder and Finder operations.

Implementing the Required Connector Framework Types

The SharePoint Server search connector framework provides the following types that you must provide implementations for in your custom indexing connector assembly:

These types are located in the Microsoft.Office.Server.Search.Connector.BDC namespace. You must add a reference to the Microsoft.Office.Server.Search.Connector.dll and the Microsoft.BusinessData.dll to use the connector framework types in the custom indexing connector assembly. The following steps describe how to do this from the Microsoft Visual Studio 2010 integrated development environment (IDE).

To add the references

  1. With the custom indexing connector project open in the Visual Studio IDE, on the Project menu, click Add Reference.

  2. On the .NET tab, select the references with the following component names, and then click OK:

    • Microsoft Search component

      You should see two entries on the .NET tab with the component name Microsoft Search component. Select the entry where the Path column is %ProgramFiles%\Common Files\Microsoft Shared\web server extensions\14\\ISAPI\Microsoft.Office.Server.Connector.dll. If this entry is missing from the .NET tab of the Add References dialog box, you must add the reference from the Browse tab by using the path to the Microsoft.Office.Server.Search.Connector.dll.

    • Microsoft SharePoint Foundation Business Data

      If this entry is missing from the .NET tab of the Add References dialog box, you must add the reference from the Browse tab. The assembly for this component, Microsoft.BusinessData.dll, is located in the same location as the Microsoft.Office.Server.Search.Connector.dll.

StructuredRepositorySystemUtility Class

The assembly must include a class that derives from the StructuredRepositorySystemUtility class, which is a partial implementation of the ISystemUtility interface. This class implements the ExecuteStatic(IMethodInstance, ILobSystemInstance, [], IExecutionContext) method, which defines the logic of how the types from the external system are reflected back for SharePoint Server search.

LobUri Class

The assembly must include a class that derives from the LobUri class, which is an implementation of the ILobUri interface. This class maps the URLs as they are passed from the Search service application to Business Connectivity Services.

INamingContainer Interface

The assembly must include a class that implements the INamingContainer interface. This class maps the URLs as they are passed from the Business Connectivity Services to the Search service application.

Defining the External Content Types

For each external content type you are returning from the external system, create a class and define the fields it should contain. In this step, you are defining an external content type's property schema.

Implementing Methods for Finder and SpecificFinder Operations

The assembly must provide method implementations for the Finder and SpecificFinder operations. The Finder operation returns all of the items from the external system. For more information, see Implementing a Finder. The SpecificFinder operation returns all of the details for a specific item from the external system. For more information, see Implementing a SpecificFinder.

Creating the BCS Model File

You must create a Business Connectivity Services model file for the custom indexing connector. For information about Business Connectivity Services model files, see Authoring BDC Models. For an example of a model file for a custom connector, see Sample BDC Model: Connecting to a Custom File System Connector.

The model for the custom indexing connector must include the properties specified in the following table.

Name

Metadata Object

Description

SystemUtilityTypeName

LobSystem

Specifies the fully qualified name of the class in the custom indexing connector assembly that inherits from the StructuredRepositorySystemUtility class.

InputUriProcessor

LobSystem

Specifies the name of the class in the custom indexing connector assembly that inherits from the LobUri class.

OutputUriProcessor

LobSystem

Specifies the name of the class in the custom indexing connector assembly that implements the INamingContainer interface.

Deploying the Custom Indexing Connector

After you deploy the custom indexing connector, you need to register it with the Search service application, and then create a content source to crawl the external data.

To register the custom indexing connector

  1. Install the custom indexing connector assembly in the global assembly cache on the application server. For additional information, see How to: Install an Assembly into the Global Assembly Cache.

  2. Copy the Business Connectivity Services model file to the application server.

  3. Open the SharePoint 2010 Management Shell on the application server. For information about using this tool, see Administering Service Applications Using the SharePoint 2010 Management Shell.

  4. At the command prompt, type and run the following command:

    $searchapp = Get-SPEnterpriseSearchServiceApplication

    Once this command completes, type and run the following command:

    New-SPEnterpriseSearchCrawlCustomConnector -SearchApplication $searchapp -protocol ProtocolName -ModelFilePath "\\ServerName\FolderName\ModelFileName.xml" -Name Name

  5. Add the following registry key to the application server:

    [HKEY_LOCAL_MACHINE]\ SOFTWARE\Microsoft\Office Server\14.0\Search\Setup\ProtocolHandlers\ProtocolName

  6. Set the value of the registry key created in the previous step to OSearch14.ConnectorProtocolHandler.1

  7. From the command prompt, type the following commands, and then run them:

    1. net stop osearch14

    2. net start osearch14

To create a content source

  1. On the Search Administration page, click Content Sources, and then click New Content Source.

  2. Type a name for the content source, and in Content Source Type, click Custom Repository.

  3. In Type of Repository, select the protocol for the custom indexing connector.

  4. In Start Addresses, specify the start address, based on the custom indexing connector protocol.

  5. Select Start full crawl of this content source, and then click OK.

See Also

Concepts

Code Sample: MyFileConnector Custom Indexing Connector

SharePoint Server Search Connector Framework

Business Connectivity Services: How-tos and Walkthroughs

Other Resources

MyFileConnector Custom Indexing Connector Sample