You may have heard about this cool feature of FAST Search for SharePoint Server 2010 (FS4SP) called user context. FAST Search user contexts allow you to use SharePoint user profile property values such as Office Location and Ask Me About (in the out-of-the-box configuration) or any other to boost search results.
This article shows how easy it is to configure a SharePoint user profile property to be used with FAST Search user contexts, define user contexts based on specific property values and then associate those user contexts with sites and documents to be boosted in search results (feature called FAST Search Site Promotions). You have an option to use SharePoint user interface or PowerShell to perform most of the configuration steps so I’ll cover both. As an example, I’m going to use standard Department user profile property to boost search results for certain SharePoint sites for different users. Users from Sales and Marketing departments will have different search results boosted for the same search term.
We’ll start by configuring the FAST user context to be based on the Department user profile property using the following PowerShell command :
Add-PSSnapIn Microsoft.SharePoint.PowerShell -ErrorAction SilentlyContinue Set-SPEnterpriseSearchExtendedQueryProperty -SearchApplication "FASTQuery" -Identity "FASTSearchContextProperties" -Value "Department"
Next we need to perform an iisreset
on the SharePoint WFE in order for the change to be reflected in the UI.
We can now add new user contexts by using different variations of the Department property values by going to Site Actions -> Site Collection Administration -> FAST Search user context -> Add User Context. Let’s go ahead and create a user context for Sales and Marketing.
If you have a large number of user contexts to be created and deployed to multiple environments then you may want to automate the process with PowerShell:
Add-PSSnapin Microsoft.FASTSearch.Powershell -ErrorAction SilentlyContinue $siteCollectionId = "69d025ce-96a7-4131-adc0-7da1603e8d24" $searchSettingGroup = Get-FASTSearchSearchSettingGroup -Name $siteCollectionId $userContext = $searchSettingGroup.Contexts.AddContext("Sales") $expression = $userContext.AddAndExpression() $expression.AddMatchExpression("Department", "Sales") $userContext = $searchSettingGroup.Contexts.AddContext("Marketing") $expression = $userContext.AddAndExpression() $expression.AddMatchExpression("Department", "Marketing")
Note that the commands above need to be executed on the FAST Search server and remember to use the site collection ID of the site collection that hosts your search center site. As you can see, the script approach is much more flexible than the SharePoint user interface in terms of the expressions you can use to define the context.
Once the user contexts are setup, you should see something similar on the Manage User Context page:
Next we are going to add a couple of site promotions and associate each one with a different user context. Navigate to Site Settings -> Site Collection Administration -> FAST Search site promotion and demotion -> Add Site Promotion, then add the Sales team site url to the Promoted Sites list and Sales user context to the User Context list:
Follow the same steps to create another site promotion but this time for the Marketing team site.
An alternate way of creating site promotions would be using the following PowerShell commands:
Add-PSSnapin Microsoft.FASTSearch.Powershell -ErrorAction SilentlyContinue $siteCollectionId = "69d025ce-96a7-4131-adc0-7da1603e8d24" $searchSettingGroup = Get-FASTSearchSearchSettingGroup -Name $siteCollectionId $siteUri = New-Object -TypeName System.Uri -ArgumentList "http://intranet.contoso.com/sales" $sitePromotion = $searchSettingGroup.PromotionsWithoutKeyword.AddPromotion("Sales") $sitePromotion.PromotedItems.AddPromotedLocation($siteUri) $sitePromotion.Contexts.AddContext("Sales") $siteUri = New-Object -TypeName System.Uri -ArgumentList "http://intranet.contoso.com/marketing" $sitePromotion = $searchSettingGroup.PromotionsWithoutKeyword.AddPromotion("Marketing") $sitePromotion.PromotedItems.AddPromotedLocation($siteUri) $sitePromotion.Contexts.AddContext("Marketing")
When creating site promotions using PowerShell, you also have the ability to specify a boost value other than the default value of 1000. Simply set the $sitePromotion.BoostValue
property to the desired value.
Finally, we are ready to verify if the search result boosting actually works. We are going to use the FAST Search for SharePoint 2010 Query Logger tool to take a look at the FQL commands being submitted and executed on the FAST query server. If we execute a search query in SharePoint using credentials of a user account having the Department user profile value set to Sales, we’ll see that an additional xrank
expression has been added to the original query:
As you can see, the boost of 1000 points has been added to the final rank of the sales presentation document located on the Sales team site:
I hope you find it useful to see a specific example of creating FAST Search user contexts and site promotion in both SharePoint user interface and with PowerShell. In my next post, I’ll expand on the topic of user contexts and show an example of best bets targeting.