FAST Search User Contexts and Best Bets in SharePoint 2010

In the previous post FAST Search User Contexts and Site Promotions in SharePoint 2010 I covered the overall concept of FAST Search User Contexts in SharePoint 2010 and provided instructions necessary to configure user contexts with SharePoint user interface and PowerShell scripts. This short post expands the topic and shows how to create best bets and associate them with specific user contexts.

The scenario is going to be very simple – for the “team site” search query we will display the Sales Team Site best bet to users from the Sales department and Marketing Team Site best bet to users from the Marketing department.

First of all, we need to create a FAST Search keyword for the “team site” phrase. You can do that by navigating to Site Settings -> Site Collection Administration -> FAST Search keywords -> Add Keyword:

Next, click the newly added keyword and then Add Best Bet. Enter the Title, Description and the URL for the best bet:

Press the Add button in the User Context and select the user context:

Repeat the steps above to add a best bet and associate it with the other user context. If we now login to the site as a user from the Sales department and execute the search for “team site” then that’s what we are going to get back. You can see that only the best bet for the Sales Team Site is displayed to the user:

Similarly, only the Marketing Team Site best bet is displayed to the user from the Marketing department:

Here’s the PowerShell equivalent (the script assumes that you created the Sales and Marketing user contexts from the previous blog post and that the site collection ID matches your search center site host):

Add-PSSnapin Microsoft.FASTSearch.Powershell -ErrorAction SilentlyContinue

$siteCollectionId = "69d025ce-96a7-4131-adc0-7da1603e8d24"
$searchSettingGroup = Get-FASTSearchSearchSettingGroup -Name $siteCollectionId

$keyword = $searchSettingGroup.Keywords.AddKeyword("team site")

$uri = New-Object -TypeName System.Uri -ArgumentList "http://intranet/sales"
$bestBet = $keyword.AddBestBet("Sales Team Site", $uri)
$bestBet.Description = "This is the Sales Team Site"
$bestBet.Contexts.AddContext("Sales")

$uri = New-Object -TypeName System.Uri -ArgumentList "http://intranet/marketing"
$bestBet = $keyword.AddBestBet("Marketing Team Site", $uri)
$bestBet.Description = "This is the Marketing Team Site"
$bestBet.Contexts.AddContext("Marketing")