Monday, March 11, 2013

SharePoint 2010 .Net Shim for Search

Recently I was faced with a task to include a file share content to SharePoint 2010 Search, but with a twist.  The users wanted to associated metadata to each of the files within the file share, however, the file share contented an array of file extension ranging from mdb, kmz, doc, xml, and kml types.  The metadata was stored at the folder level in it's own xml file.  So to recap, this product will outline a .Net Shim exposing an external content source to SharePoint 2010.  The .Net Shim walks the file share and assoicates the folder level metadata stored within a *.xml file to each indexed object within SharePoint 2010 Search.  The SharePoint 2010 Search implements FAST as the crawler.

Visual Studio 2010 Project

So to start the proejct, I decided to use Visual Studio 2010.   I used this site to get started: 
Creating External Content Types with Visual Studio 2010.    Where my implemenation differs from this example is my entity class was based upon source code that read content from a file share and assoicated the corresponding metadata information with each file. 

The good thing about using Visual Studio 2010 with a SharePoint project is that a Visual Studio creates a deoployment package - a wsp file for you.

Project file structure
The Bdc model looks like this:

BDC Model

The BdcModel.bdcm file contains and entity that looks like this:


So far there is not really anything new here from other implemenations, the the "Data" object is servered to the BDC model from the .Net Shim itself.  So looking at the file structure the "DataService.cs" file is the heavy lifter that contains the "ReadList", "ReadItem" and "GetDocument" function calls.

Looking into this file at the "ReadList" function:


This function is small but powerful.  First it logs an information notice that the function has been invoked to SharePoint Unified Logging Service (ULS) for tracing purposes.  Next it invokes a function that performs the file share read and metadata association.

Look at the "GetAllData" function which performs the file share read and metadata assoication.

Related Links:

Creating External Content Types with Visual Studio 2010
Searching External Data in SharePoint 2010 Using Business Connectivity Services
BCS Shims – .NET assembly as a data source for Business Connectivity Services
Configuring Business Connectivity Services (BCS) Search in SharePoint 2010
Business Data Connectivity Model – Finder Method
Using Business Connectivity Services in SharePoint 2010
HOW TO: Create a Searchable SharePoint 2010 BDC .NET Assembly Connector Which Reads From A Flat File
BDC .NET Assembly Connector: Tame SharePoint Search to search your .NET BDC Entity
Using Sharepoint’s File Type Icons
Developing a BDC Model on Visual Studio 2010 for SharePoint Foundation 2010 – The BDC Model and external references

Search Center configuration links:
Configuring SharePoint Server 2010 Search for External Content Types (Part 1 of 2)

FAST related links:
Mapping crawled properties (FAST Search Server 2010 for SharePoint)
Property Management

Issue related link:
SharePoint 2010 BDC Model Deployment Issue: “The default web application could not be determined.”

Yea, I know this is SharePoint 2007, but it has some good information in it:
Performing Incremental Crawling with the Business Data Catalog in SharePoint Server 2007

No comments:

Post a Comment