Best Bets – and nothing but the Best Bets!
In FAST Search for SharePoint (FS4SP), Best Bets are result items that are added manually to the results of a search query. But unless you edit the web part, FS4SP will also show you the Keyword Definition along with the Best Bets. Or…?
Let’s take it from the beginning. Using Best Bets, i.e. hard-wiring a certain result item to a particular search term, is a great way for Search Administrators to make sure end-users find what they’re looking for. Interestingly enough, there’s sometimes a slight contempt towards Best Bets in the technical community. Some people seem to think that the search solution’s relevance model should be able to stand on its own, and make sure the best results are always returned at the top of the results anyway.
But as a Search Administrator, if you could increase the perceived end-user experience a lot by a just a little manual (or semi-automatic) labor, wouldn’t you do it? Sure you would. One way of doing that is simply to look into the top X search queries in your query logs, and spend a few minutes on each search query and hard-wire a certain result item against it.
Anyway – we’re on the Technology section, so let’s get dirty.
In FS4SP, Best Bets are managed through the FAST Search Keywords page under Site Collection Administration. Adding a new one is easy: you start by creating a keyword, and then attach a Best Bet to it. Simple enough.
Let’s say you added the keyword “Comperio”, with the definition “Microsoft Search Partner of the Year 2011”. You then attached a Best Bet to it, linking to Comperio’s web site. With the minimal configuration, you’d end up with something like this:
Cool! You got yourself a Best Bet, and this is how they’re shown on the majority of FS4SP deployments out there. However, the Best Bet is not the only thing showing. The first star is showing the keyword itself, a long with its definition.
Let’s say you want to save some pixel real-estate, and decides that showing just the link is enough. At the Edit Keyword page, there’s no switch saying if to show the definition or not, but you can remove the text altogether from the text area shown below. That ought to do it!
Unfortunately, the result is not much better. We still get two stars, only now the keyword definition text is removed. The keyword itself is floating around by its own above the Best Bet – and not a single pixel was saved from vertical misery.
There’s no other setting on the FAST Search Keywords page to fix this – but there’s still a nice work-around. Enter PowerShell!
In an FS4SP shell, get hold of a Search Setting Group object corresponding to your Site Collection. If you only have one site collection, you can do:
1 |
$ssg = Get-FASTSearchSearchSettingGroup |
If you have more than one, and haven’t named the group manually, pass in the id of your site collection to the the cmdlet’s –Name parameter. Running the two lines below in a SharePoint Management shell will print the id:
1 2 |
$site = Get-SPSite -Identity <a href="http://<site collection root>">http://<site collection root></a> $site.ID |
When you’ve got hold of the search setting group, you can use it to view all internal information about the keyword:
1 2 3 4 5 6 7 8 9 10 |
PS C:\FASTSearch\bin> $ssg.Keywords.GetKeyword("comperio") Synonyms : {} BestBets : {Comperio} FeaturedContent : {} Promotions : {} Group : Microsoft.SharePoint.Search.Extended.Administration.WCFClient.SearchSettingGroupImplWCF Definition : <DIV>&nbsp;</DIV> Term : comperio LastChanged : 1/27/2012 12:36:57 AM Id : 2 |
Looking at the Definition property, you’ll notice that’s it not actually empty at all – even though you’ve clearly removed all text from the definition text area. It contains the HTML entity for a non-breaking space wrapped in a <div> tag! Turns out that if you use the GUI to clear the definition, this is literally as empty you can make it. Even on a brand new keyword, without even specifying a definition. Bug or feature? I don’t know. But now knowing what the problem is, you can easily fix it for yourself by running:
1 2 |
PS C:\FASTSearch\bin> $keyword = $ssg.Keywords.GetKeyword("comperio") PS C:\FASTSearch\bin> $keyword.Definition = $null |
And with no further a due, your Best Bet is finally standing strong – on its own!
Can I have the best bet with the definition as a description?
Unless you modify the XSLT, I don’t think so.
[...] In SharePoint Search”. Mikael Svenson has done a very good job of explaining the details of an earlier article about best bets (content which may of interest to a user) enhancements to SharePoint [...]
Generally you will have some HTML formatting in the Keyword Definition field, usually “”. If you remove that it will take care of the issue as well.
What’s tricky about this is that the HTML formatting usually won’t display in Chrome or IE. I’ve only ever seen it display in Firefox, so if you open the Keyword and edit it via Firefox you will see that HTML formatting and can simply remove it.