November Happy Hour will be moved to Thursday December 5th.
November Happy Hour will be moved to Thursday December 5th.
I don't think there's super easy way to do that. However, best bets are stored in the DDS meaning that you can retrieve them and then do pretty much anything you like. Some pseduoish code:
using EPiServer.Find.Framework.BestBets;
var queryParam = "Banana";
var repo = new BestBetRepository();
var allBestBets = repo.List();
//Only checking phrase here, you may also want to check site and language
var matching = allBestBets.Where(x => x.PhraseCriterion.Match(queryParam);
The matching variable now contains relevant best bets. Using these you could either figure out the ID of matching pages and files, for instance:
var pageLinks = matching
.Select(x => x.BestBetSelector).OfType<PageBestBetSelector>()
.Select(x => x.PageLink);
Or, you could use them to do pretty much what you described above (again pseudoish):
var filter = SearchClient.Instance.BuildFilter<ISearchContent>();
foreach(var selector in matching.Select(x => x.BestBetSelector))
{
filter = filter.Or(selector.GetTargetSelectionFilter());
}
SearchClient.Instance.UnifiedSearchFor(queryParam, Language.Swedish).
.Filter(x => filter)
.GetResult();
Thanks! I can work with that...
For this search page I'm building best bets should be listed completly separate from the other results.
We can live with them being the first hits of the normal result list but I'd still need to identify them for separate styling.
Because UnifiedSearchHit doesn't have a IsBestBet bool property or similiar not-having-to-visit-the-DDS-store-myself-way right?
Yeah. The way best bets work in Find they are applied at query time. This means that it's optional to use them (for instance you may not want them in editorial search) and they are applied instantly. However, it also means that the search engine doesn't know about them. What you could in theory do is inspect the score for each hit. If the first hit(s) have significantly higher score it may be safe to assume that it's a best bet.
Alternatively you could figure out what pages are best bets using something like the first two code snippets above and then when you get the result back compare each hit to those pages.
Alternatively you could figure out what pages are best bets using something like the first two code snippets above and then when you get the result back compare each hit to those pages.
OK, thanks for the info! I have something like that in play now.
var bestBetsResults = SearchClient.Instance.UnifiedSearchFor(queryParam, Language.Swedish).ApplyBestBets().GetResult();
Is it possible to have something like that but ONLY get best bet hits added from Find admin?