Anders Hattestad
Feb 18, 2016
  3898
(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 PaaS CMS Administrator Certification (2025): What to Expect and How to Prepare

The Optimizely PaaS CMS Administrator certification is best understood as training for the operational side of Optimizely CMS. It focuses on how th...

Augusto Davalos | Jun 2, 2026

Creating Read-Only Calculated Fields in Optimizely Commerce 14

Introduction In many Optimizely Commerce projects, product information comes from external systems such as ERPs, PIMs, inventory management systems...

Ankit Agarwal | Jun 2, 2026

Pushing Content Between Optimizely DXP Environments

We've been working with a client who has been on Optimizely 11 for a long time - self-hosted, on their own server infrastructure, with a content...

Matt Pallatt | Jun 2, 2026

Launching “Learning by Doing – Optimizely OPAL Series” | Episode 01 is Live!

  Introduction With Optimizely OPAL, we’re seeing a shift from "content management" to "intelligent content orchestration". But here’s the reality ...

Ratish | Jun 1, 2026 |