Don't miss out Virtual Happy Hour this Friday (April 26).

Try our conversational search powered by Generative AI!

Filter out best bets in typed search


From i see that IsBestBet() (i states that the method is called IsBestBetStyle, but it seems to be a typo?) and HasBestBetStyle() only work for unified search. Is there now way of telling if a hit in types search is a result of best best settings?


Bjørn Terje Svennes

Running .Net client version

Dec 02, 2021 11:58

Yes, you can tell in Typed Search using the Best Bet Repository class.

Check out the ApplyBoostedProperties method in the Foundation Search Service

Foundation/SearchService.cs at develop · episerver/Foundation (

        /// <summary>
        /// Sets Featured Product property and Best Bet Product property to ProductViewModels.
        /// </summary>
        /// <param name="productViewModels">The ProductViewModels is added two properties: Featured Product and Best Bet.</param>
        /// <param name="searchResult">The search result (product list).</param>
        /// <param name="currentContent">The product category.</param>
        /// <param name="searchQuery">The search query string to filter Best Bet result.</param>
        private void ApplyBoostedProperties(ref List<ProductTileViewModel> productViewModels, IContentResult<EntryContentBase> searchResult, IContent currentContent, string searchQuery)
            var node = currentContent as GenericNode;
            var products = new List<EntryContentBase>();

            if (node != null)
                UpdateListWithFeatured(ref productViewModels, node);

            var bestBetList = _bestBetRepository.List().Where(i => i.PhraseCriterion.Phrase.CompareTo(searchQuery) == 0);
            //Filter for product best bet only.
            var productBestBet = bestBetList.Where(i => i.BestBetSelector is CommerceBestBetSelector);
            var ownStyleBestBet = bestBetList.Where(i => i.BestBetSelector is CommerceBestBetSelector && i.HasOwnStyle);
                             .ForEach(p =>
                                 if (productBestBet.Any(i => ((CommerceBestBetSelector)i.BestBetSelector).ContentLink.ID == p.ProductId))
                                     p.IsBestBetProduct = true;
                                 if (ownStyleBestBet.Any(i => ((CommerceBestBetSelector)i.BestBetSelector).ContentLink.ID == p.ProductId))
                                     p.HasBestBetStyle = true;
Dec 03, 2021 12:13

Thank you very much, Johnny. This will do the trick.

Dec 03, 2021 14:22
Johnny Mullaney - Dec 03, 2021 14:23
No problem Bjorn. Glad my answer helped!
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.