When you create a custom BDC External Content Type (or “Entity”) for use in SharePoint 2010 and deploy it in the Business Data Connectivity Service Application, it will not be “crawlable” from the SharePoint search application by default.
There is a great article from Chaks here on the detail, so I do not see any need to repeat the article he has written. However, one approach that may be preferable when configuring the entity and Lob System Instance could be to use PowerShell instead.
In my example, I have created a very simple External Content Type (ECT) to show a people table from a SQL database. As you can see from the screenshot below, the option to crawl the ECT is set to “No”:
To retrieve the ECT for configuration in PowerShell, you can use the Get-SPBusinessDataCatalogMetadataObject cmdlet provided with SharePoint 2010. The script below will retrieve the “People” ECT shown above:
$entity = Get-SPBusinessDataCatalogMetadataObject -BdcObjectType "Entity" -Name "People" -Namespace "http://portal.pacdomain.local" –ServiceContext “http://centraladminURL:port”
Next, the following lines of script retrieve the “ReadList” method instance, as suggested in Chaks article:
$methodinstance = $entity.MethodInstances | where {$_.Name -eq "ReadList"}
It is here that we need to add the “RootFinder” property. If you wish to view a list of the current properties set on the method instance, simply type $methodinstance.Properties. To add a new property, type the following command:
$methodinstance.Properties.Add("RootFinder", "")
You may also wish to switch on the optional “UseClientCachingForSearch” property, which can speed up the crawls to the ECT, but ensure that you read this article first before doing so as there are some caveats to think about:
$methodinstance.Properties.Add("UseClientCachingForSearch", "")
Once you have finished making these changes, update the method instance as follows:
$methodinstance.Update()
The ECT will now show as “Crawlable”:
Note, that you can also use the “Remove” method to delete any property set on the method instance. This could be used to remove the search option on an ECT – even those created in SharePoint Designer, where the “crawlable” option is switched on by default. For example, type the following to remove the “UseClientCachingForSearch” property:
$methodinstance.Properties.Remove("UseClientCachingForSearch")
$methodinstance.Update()
Next, we need to switch on the “ShowInSearchUI” property for the Lob System Instance. This allows the BDC model instance to be seen in the SharePoint search administration interface when creating a content source to crawl business data. At this point you will need to know the name of the Lob System Instance for this ECT – if you’re not sure what this is, type $entity.LobSystem.LobSystemInstances to find it. In this example, the name is “Test Database”:
We can now use this name to get the Lob System Instance, configure the ShowInSearchUI property, and update the item:
$lobSI = $entity.LobSystem.LobSystemInstances | where {$_.Name -eq "Test Database"}
$lobSI.Properties.Add("ShowInSearchUI", "")
$lobSI.Update()
Again, the property can be removed using the “Remove” method as before, should you wish to hide a Lob System Instance from the search administration interface again.
Thank you !!! for sharing above power shell code pointers...it was very useful for me ..
ReplyDelete