Friday, January 27, 2012

How to do Visual Best Bets for built-in SharePoint Search

Marcus Johansson did a post about the use of Best Bets this morning which inspired me to write this post. Read his post for more thoughts around the use of best bets.

Visual Best Bets is a feature of FAST Search for SharePoint which lets you point to a file with html content to be displayed above your search results. For example an image, silverlight or flash content can be used to graphically enhance what is linked to the keyword term. The Visual Web Part uses an iframe to accomplish this and loads up your content inside the iframe. This is useful as you can easily edit the html file at will.

But why go the extra mile for a separate file, or opt in for FS4SP for this feature? The Best Bet web part support the showing of keywords and keyword definitions. Keyword definitions are formatted as html. And a definition with html formatting is in effect a Visual Best Bet. (If you have more than one Visual Best Bet you want to assign to the keyword you would have to add them all to the same html for this to work.)



If we examine the Add Keyword page you can format the text for the definition, but there is no button to allow editing the html directly in the style panel.
image
Will this stop us? No, because we have PowerShell! In a SharePoint management shell get hold of the added keyword “fs4sp” and look at the properties:
PS C:\Users\svc_spadmin> $keyword = Get-SPEnterpriseSearchQueryKeyword -Site http://test "fs4sp"
PS C:\Users\svc_spadmin> $keyword  | Format-List


Term       : fs4sp
Definition :
Contact    :
StartDate  : 26.01.2012 23:00:00
EndDate    : 31.12.9999 23:59:59
ReviewDate : 31.12.9999 23:59:59
BestBets   : {}
Synonyms   : {}
ExpiryDate : 31.12.9999 23:59:59
As you can see there is a property called “Definition”. This parameter holds html, but is empty as I didn’t add a definition via the UI.

For my Visual Best Bet I will add the following html to my $keyword object and update it:

PS C:\Users\svc_spadmin> $keyword.Definition = '<div><img src="http://test/PublishingImages/FAST-search-server
-2010.png" style="float:left"><b>Working with Microsoftr FAST Search Server 2010 for SharePointr, 1st Edition<
/b><i>By Mikael Svenson, Marcus Johansson, Robert Piddocke</i>Deliver the tools clients need to navigate large
 stores of information on your Microsoftr SharePointr implementation-using Microsoft FAST Search Server 2010 f
or SharePoint.<br>Format: Print<br>Publish Date: March 2012</div>'
PS C:\Users\svc_spadmin> $keyword.Update()
Next edit the Search Best Bet web part and make sure “Display definition” is checked and that “Display keyword” is unchecked.


image

Do a search for “fs4p” and the result looks like this:

image

If you want to use an iframe pointing to a separate file you can add html like:

<IFRAME title="Search Visual Best Bet" height="150" src="http://fs4spbook.com/" frameBorder="0px" scrolling="no"></IFRAME>

where the src tag points to your file to mimic the behavior  of the Visual Best Bets web part.

All part of a days work using configuration!

No comments:

Post a Comment