Languages

Vote:
 

Hi,

How do I handle pages published in different languages in Find? For example, I have a page published first in Finnish and then in English. Now when I search for it Find returns it in both languages even though I specifically defined that I'm only interested in finding pages in Finnish.

Here's the code:

var language = Language.GetAll().First(f => f.Name == ContentLanguage.PreferredCulture.EnglishName);
var query = SearchClient.Instance.Search<StationPage>(Language);
var results = query.StaticallyCacheFor(TimeSpan.FromHours(1)).Take(MAX_SEARCH_RESULTS).Take(MAX_SEARCH_RESULTS);

I checked with debugger that "language" is Finnish.

How do I tell Find that I'm only interested in pages in particular language? Or do I have to filter results "by hand"?

#66181
Feb 22, 2013 9:06
Vote:
 

Hi Marko,

The language parameter that you are passing to the query does not filter hits, it tells Find how to interpret the query regarding language (if it should use stemming in any way). If you want to have only pages for a specific language branch returned you have to filter on that specific branch by using the FilterOnLanguages-extension in the EPiServer.Find.Cms-namespace:

client.Search<IContent>()
.FilterOnLanguages(new string[] { "sv" })
...

Regards,

Henrik

#66219
Feb 25, 2013 9:05
Vote:
 

Ach. Thank you. I'll try that.

#66220
Feb 25, 2013 9:36
Vote:
 

Is FilterOnLanguages() only available for CMS 7 or am I blind? ;)

#66266
Feb 26, 2013 9:51
Vote:
 

But I guess that this would give me the same result? ".Filter(x => x.LanguageID.Match(CurrentPage.LanguageID));"

#66269
Feb 26, 2013 10:04
This topic was created over six months ago and has been resolved. If you have a similar question, please create a new topic and refer to this one.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.