SaaS CMS has officially launched! Learn more now.

Anders Hattestad
Feb 18, 2016
  3099
(2 votes)

When EPiServer.Search's Score is zero

I got a problem with the search result using EPiServer.Search. The site is in Norwegian and is set to default langauge in site settings in admin.

But the result from the search always gave me 0 for result on the IndexResponseItem Score.
After some digging around I found this code

indexResponseItem.Score = (float.TryParse(RequestHandler.GetAttributeValue(current, SearchSettings.Config.SyndicationItemAttributeNameScore), out num2) ? num2 : 0f);

Beeing executed in RequestHandler.PopulateSearchResultsFromFeed
And since my current Culture will be set to "no" since the host sets it to that, the result from IndexService/IndexingService.svc will return results in "en" then I got problems

The quick solution is to change the current culture before one search and set it back after.

var section = ConfigurationManager.GetSection("system.web/globalization") as GlobalizationSection;
var oldCulture = Thread.CurrentThread.CurrentCulture;
if (section!=null )
{
    Thread.CurrentThread.CurrentCulture=CultureInfo.GetCultureInfo(section.UICulture);
}
var res= SearchHandler.Instance.GetSearchResults(groupQuery, 1, maxSize);
Thread.CurrentThread.CurrentCulture = oldCulture;
return res;

I Guess there are more correct ways of doing this, but a solution is better than none :)

Feb 18, 2016

Comments

Please login to comment.
Latest blogs
Optimizely SaaS CMS Concepts and Terminologies

Whether you're a new user of Optimizely CMS or a veteran who have been through the evolution of it, the SaaS CMS is bringing some new concepts and...

Patrick Lam | Jul 15, 2024

How to have a link plugin with extra link id attribute in TinyMce

Introduce Optimizely CMS Editing is using TinyMce for editing rich-text content. We need to use this control a lot in CMS site for kind of WYSWYG...

Binh Nguyen Thi | Jul 13, 2024

Create your first demo site with Optimizely SaaS/Visual Builder

Hello everyone, We are very excited about the launch of our SaaS CMS and the new Visual Builder that comes with it. Since it is the first time you'...

Patrick Lam | Jul 11, 2024

Integrate a CMP workflow step with CMS

As you might know Optimizely has an integration where you can create and edit pages in the CMS directly from the CMP. One of the benefits of this i...

Marcus Hoffmann | Jul 10, 2024