Hi Petter!
I tested in EPiServer Find 8.9 and it all works great for me. Maybe you have an older version?
I tested added one best bet for site1 and one for site2.
Testing the best bet for site1 in site1 succeeded. Testing the best bet for site2 in site1 failed.
Testing the best bet for site2 in site2 succeeded. Testing the best bet for site1 in site2 failed.
So at least it seems to work as intended for me...
Maybe you did not have UnifiedSearchFor? My query looks like this:
ITypeSearch<ISearchContent> query = SearchClient.Instance.UnifiedSearchFor(q).ApplyBestBets<ISearchContent>(); model.Results = query.GetResult();
Hi Samuel,
Thanks for helping out with the testing.
No I'm not using the UnifiedSearchFor. I'm using the typed search. Query looks something like:
var query = searchInstance.Search<BasePageData>(Language.Swedish) .For(args.Query) .InField(x => x.SearchTitle()) .AndInField(x => x.SearchText()) .AndInField(x => x.SearchCategories(), 0.25) .UsingSynonyms(); ... Lots of filters added .... Projection added .. query.Skip((currentPage.PagingPage - 1) * currentPage.HitsToShow) .Take(currentPage.HitsToShow) .ApplyBestBets() .Track().StaticallyCacheFor(TimeSpan.FromMinutes(5)) .GetResult();
Do you get the same result using typed search and searching in fields?
Hi Petter!
I did not get your code to work either. But I think GetContentResult() should be used when working with the EPiServer CMS. I think GetRetResult is more used for non EPiServer objects, but I might be wrong. Quite new to Find too ;)
I modified your code a bit and got it to work. The query I uses was:
var query = SearchClient.Instance.Search<SitePageData>(Language.English) .For(q) .InField(x => x.SearchTitle()) .AndInField(x => x.SearchText()) .AndInField(x => x.SearchCategories(), 0.25) .UsingSynonyms(); var result = query.Skip(skipNumber) .Take(pageSize) .ApplyBestBets() .Track().StaticallyCacheFor(TimeSpan.FromMinutes(5)) .GetContentResult();
As you can see the most significant change is just using .GetGontentResult() instead of .GetResult().
Is that working for you?
He is using projections, so GetContentResult cannot be used. However, it should work with GetResult as well.
Petter, which language(s) has the best bet been added to? Also, is Swedish enabled as a stemming language on your index?
The best bet is added to "all languages". Not sure about the stemming part as we aren't the Licence partner for the customer. But can I check that somewhere?
Sounds strange. Could it be something wrong with the context of your search? If you debug, is the current site property correct if you invoke:
ServiceLocator.Current.GetInstance<ISiteIdentityLoader>().CurrentSite;
Hmm no getting the right CurrentSite. And well if that was Fubar wouldn't it just give me all the statistics on one of the sites? Currently I'm not getting any for a specific site but just on all.
Not sure how your usings look like but if you have added
using EPiServer.Find.Statistics;
then try
using EPiServer.Find.Framework.Statistics;
instead. I had problems with this on another site where for example my searches were stored under "All websites" instead of the specific websites.
Ha! Just did that for a nother issue I was having with the tracking and was thinking it could be related.
I'll give it a spin and see where we land but guessing it will solve the issue for me.
Thanks for all the help guys
Is there any magic that I'm missing to applying site specific best bets?
Currently we are just using the .ApplyBestBets() function and it doesn't seem to take any sitedefinition info. But none of the site specific best bets show up just the global ones.