Anders Hattestad
Feb 18, 2016
  3153
(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
Integrating Optimizely DAM with Your Website

This article is the second in a series about integrating Optimizely DAM with websites. It discusses how to install the necessary package and code t...

Andrew Markham | Sep 28, 2024 | Syndicated blog

Opticon 2024 - highlights

I went to Opticon in Stockholm and here are my brief highlights based on the demos, presentations and roadmaps  Optimizely CMS SaaS will start to...

Daniel Ovaska | Sep 27, 2024

Required fields support in Optimizely Graph

It's been possible to have "required" properties (value must be entered) in the CMS for a long time. The required metadata haven't been reflected i...

Jonas Bergqvist | Sep 25, 2024

How to write a bespoke notification management system

Websites can be the perfect vehicle for notifying customers of important information quickly, whether it’s the latest offer, an operational message...

Nicole Drath | Sep 25, 2024

Optimizely DAM – An Introduction

I presented a talk about the Optimizely DAM at the OMVP summit during Opticon 2024 in Sweden. I have now converted that talk into two blog posts....

Andrew Markham | Sep 25, 2024 | Syndicated blog

Simple and Effective Personalization with Optimizely Data Platform (ODP)

As we dive into the amazing capabilities of Optimizely One, let’s shine a spotlight on the Optimizely Data Platform (ODP). This simple tool unifies...

Alex Harris - Perficient | Sep 24, 2024 | Syndicated blog