Try our conversational search powered by Generative AI!

Loading...
Area: Optimizely Search & Navigation
ARCHIVED This content is retired and no longer maintained. See the latest version here.

Recommended reading 

Best Bets let you promote selected content when a search query matches a specific phrase. Best Bet content appears at the top of search results because it has a higher boost weight.

Applying Best Bets

Use ISearch or ITypeSearch in EPiServer.Find namespace to apply Best Bets to the search results, as shown in the following example.

Unified Search

C#
var results = client.UnifiedSearchFor("Beethoven").ApplyBestBets().GetResult();

You can apply an overload that accepts a boost index (ApplyBestBets(double? boost)), which affects the influence of a matching Best Bet on the search result score (default is 1000).

C#
var results = client.UnifiedSearchFor("Beethoven").ApplyBestBets(200).GetResult();

Typed Search

You also can apply Best Bets to arbitrary types that you have indexed, as shown in the following example.

C#
var results = client.Search<Contact>For("Beethoven").ApplyBestBets().GetResult();

Styling Best Bet search results

To style Best Bet search results, first use IsBestBetStyle() to see whether a search hit is a Best Bet. Then, use HasBestBetStyle() to see whether the Best Best is shown using its own style. IsBestBetStyle() and IsBestBetStyle() are available for UnifiedSearchHit.

C#
if(hit.Document.IsBestBet && hit.Document.HasBestBetStyle) { ... }

For HasBestBetStyle() to return true, you must select the Show the best bet with its own style check box on the Find admin UI. Otherwise, the function returns false, indicating the style is not added to the listing.

See also: UnifiedSearch.

Do you find this information helpful? Please log in to provide feedback.

Last updated: Sep 21, 2015

Recommended reading