Freigeben über


How to enable search alerts across farms

Search alerts in SharePoint 2010 is a pretty powerful feature, and enabling it in Enterprise Search is easy; just click “Enable” next to the “Search alerts status” in the in the Search Administration page for a search service application, and you’re good to go.

This is true for the local farm, but if you’re in an environment where you have a search service application that’s shared between farms, you need to configure which farms the search service application should allow search alerts for.

The ULS log on a farm that is consuming a search service application from another farm gets the following error when the “Immediate Alerts” timer job tries to process a search alert:

SearchServiceApplicationProxy::Execute--Error occured: System.ServiceModel.FaultException`1[System.ServiceModel.ExceptionDetail]: Error while processing search alert at search service application 'Search Service Application'. Farm Id 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx' does not exist in the FarmIdsForAlerts property or is not the local farm id 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'. (Fault Detail is equal to An ExceptionDetail, likely created by IncludeExceptionDetailInFaults=true, whose value is: System.InvalidOperationException: Error while processing search alert at search service application 'Search Service Application'. Farm Id 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx' does not exist in the FarmIdsForAlerts property or is not the local farm id 'xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx'

This is a really informative error message! The SearchServiceApplication object has a property called FarmIdsForAlerts, which is a list of farm ids. All farms that should have search alerts must be listed here (not necessary to list the local farm). To add the first farm id to the list, you can use PowerShell:

# Id of farm to allow search alerts for
$guid = new-object "System.Guid" -ArgumentList "{dc08d452-dea8-4091-848b-2bbbcab448d4}"

$app = Get-SPEnterpriseSearchServiceApplication -Identity "Search Service Application"

# Create list and add farm id
$type = ("System.Collections.Generic.List"+'`'+"1") -as "Type"
$type = $type.MakeGenericType("system.Guid" -as "Type")
$list = [Activator]::CreateInstance($type)
$list.Add($guid)
$app.FarmIdsForAlerts = $list
$app.Update()

For consecutive farm ids, you can create the $list variable the same way as shown here, add the $guid to the list, loop through the current $app.FarmIdsForAlerts list and add its entries to the $list variable, set the $app.FarmIdsForAlerts = $lists, and then do $app.Update() .