Don't miss out Virtual Happy Hour this Friday (April 26).

Try our conversational search powered by Generative AI!

Anders Hattestad
Feb 18, 2016
  3062
(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
Solving the mystery of high memory usage

Sometimes, my work is easy, the problem could be resolved with one look (when I’m lucky enough to look at where it needs to be looked, just like th...

Quan Mai | Apr 22, 2024 | Syndicated blog

Search & Navigation reporting improvements

From version 16.1.0 there are some updates on the statistics pages: Add pagination to search phrase list Allows choosing a custom date range to get...

Phong | Apr 22, 2024

Optimizely and the never-ending story of the missing globe!

I've worked with Optimizely CMS for 14 years, and there are two things I'm obsessed with: Link validation and the globe that keeps disappearing on...

Tomas Hensrud Gulla | Apr 18, 2024 | Syndicated blog

Visitor Groups Usage Report For Optimizely CMS 12

This add-on offers detailed information on how visitor groups are used and how effective they are within Optimizely CMS. Editors can monitor and...

Adnan Zameer | Apr 18, 2024 | Syndicated blog