Like This ...

Enabling Search on BDC

To enable search on business data, you have to go through the following steps –

·         Modify the XML to Enable Search

·         Create the Content Source and Perform a Content Crawl

·         Authentication will be a concern here so fix that

·         Setup MetaData Properties and Crawled Property Mappings

·         Create appropriate search scopes

·         Make these scopes available to your site

·         Create a custom search application

So let us perform these steps one by one.

1. Modify the XML Goo to enable search.

My intent is to make "Customers" searchable. So I am going to add an IDEnumerator kind of method instance in a new method as shown below -

<!-- A Method for enabling search.-->

<Method Name="CustomerIDEnumerator">


    <Property Name="RdbCommandText" Type="System.String">Select CustomerID from Customers</Property>

    <Property Name="RdbCommandType" Type="System.String">Text</Property>



    <Parameter Name="CustomerIDs" Direction="Return">

      <TypeDescriptor TypeName="System.Data.IDataReader, System.Data, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" IsCollection="true" Name="Customers">


          <TypeDescriptor TypeName="System.Data.IDataRecord, System.Data, Version=2.0.3600.0, Culture=neutral, PublicKeyToken=b77a5c561934e089" Name="Customer">


              <TypeDescriptor TypeName="System.String" IdentifierName="CustomerID" Name="CustomerID">


                  <LocalizedDisplayName LCID="1033">ID</LocalizedDisplayName>










    <MethodInstance Name="CustomerIDEnumeratorInstance" Type="IdEnumerator" ReturnParameterName="CustomerIDs"/>



This method returns unique IDs for customers. MOSS search will query for IDs using this method first, and then it uses the SpecificFinder method to get other metadata on the customer based on these IDs. This will allow for a full crawl. If you wish to enable incremental crawl as well, you need to also send back a field telling MOSS the last time this customer was seen/changed.

2. Create a content source and perform a content crawl.
3. Authentication will be a concern here.

In order to create a content source,

  • Go to SSP -> Search --> Search Settings and click on "Content Sources and Crawl Schedules".
  • Create a new content source
  • Specify various information to crawl NorthWindTraders. Here is how my screen looks -
  • Note that I did not request a start full crawl. I was smarter than that, because if I issue a full crawl, I know it will simply not work. Why?

This brings me to the second part - Authentication. I am using "PassThrough" authentication in the above BDC App. This means, I am logged in as "MyDomain\Sahil", and "MyDomain\Sahil" has access to the database NorthWind. Also, Sahil has access to the BDC application. So when "Sahil" tries accessing the BDC, it works. But, when Search (which is running as "MySharePointMachine\Local Service" tries accessing BDC, it bombs).

So I need to fix it. Here is how -

- Create a new account for search.
- Change the default content access account to that account. This can be done under search settings.
- Change search crawler account to that account. This can be done under operations\services on the server\office sharepoint server search
- Give this account access to NorthwindTraders
- Make this account have edit, execute & select permissions on the Northwindtraders business data catalog. Copy permissions to appropriate decendants.

The other option I have is to use a different kind of authentication (but that has it's own ramifications).


Now wait for a minute because - a) I'm tired, b) The metadata is cached for a minute, let it go through to all SSP machines.

After having waited for a minute, :), start the crawl on CustomersBDC content source you defined a moment back. I like to run SQL Server Profiler in my test environment, just to make sure that the queries are actually getting passed. You could always look at SharePoint logs also for errors, but this is just a lot easier. :-)

If you did everything right (and waited a minute as I recommended), you should see the content source crawling when you request for a full crawl as shown below -

Full Crawl

.. and your SQL Server profiler should show the relevant queries being issued -

SQL Profiler

4. Add MetaDataProperties and Crawled Properties

This is optional/icing on the cake scenario. If interested in this, Read this blogpost I wrote on Search Scopes + MetaDataProperties.

5. Create appropriate search scopes -

  • In the SSP under search settings, under the "Scopes" area, click on "View Scopes"
  • Click on "New Scope", call it CustomersBDC
  • Click on "Add Rules" where it says "Empty - Add Rules" on the newly added scope, CustomerBDC.
  • Specify a Content Source as shown below -
    Source Content
  • You should see scopes listed as below -
  • Go ahead and issue an update (I just don't feel like waiting another 9 minutes). This can be done from the main search settings page.
  • After having issue an update, you will see that the search scope Customer BDC now has 93 items populated in it.
  • Your search is now ready to use.

To use the search,

  • Go to your favorite MOSS site.
  • Go to site settings, search scopes, and change Customers BDC from unused scopes to Display group: Search Dropdown.
  • Find a page which you can customize with webparts, I'm gonna use default.aspx
  • Add the following webparts - Search Box, Search Core Results, Search Paging, Search Statistics, and Search Summary. Order them like this -
  • Change the "Target search results page URL" for the Search box to http://moss2007/default.aspx (or whatever the above page URL is).
  • Change "Results Per Page" for "Search Core Results" to 5.
  • Get out of Edit mode.
  • .. and issue a search for "Londn" (note to intentional misspelling). You should see an output like this -
  • Click on "London" to issue a search on the keyword "London" - you should see an output like this -

Note: The search results, based on the Northwind database, are not fully searchable, but they also support custom alerts, and RSS Feeds.

blog comments powered by Disqus