volume_up

A critical vulnerability was discovered in React Server Components (Next.js). Our systems remain protected but we advise to update packages to newest version. Learn More

AI OnAI Off

LanguageRoutingFactory for fallback language

This relates to https://world.optimizely.com/forum/developers-add-ons-forum/Search/Thread-Container/2019/11/unified-search-not-finding-content-in-fallback-language/

I am not able to get search hits from fallback language.

Say I have set fallback for en-CA to en-GB. Navigating and seeing content is no problems.

When I perform a search however, I just get hits on pages/content that are published on current language. I wish to get hits from the fallback language (en-GB) as well.

 

I have implemented a FallbackLanguageRoutingFactory which inherits from LanguageRoutingFactory and an Initialization Module for IndexingModule which adds singleton.

I am not able to get the result as expected.

Could this be due to the demo index I am using?!

 

Using EPiserver.Find.Cms 16.4.1

#337755
Apr 08, 2025 11:49

When performing a search, the language context of the query matters. If you're searching in en-CA, the search provider might only return results in that language, unless explicitly configured to include fallback.

You might need to manually include fallback languages in your search query. For example:

var searchLanguages = new[] { "en-CA", "en-GB" }; // include fallback
var results = searchClient
    .Search<YourContentType>()
    .Filter(x => x.Language.MatchAny(searchLanguages))
    .GetResult();
 
#340868
Oct 30, 2025 5:52

Are you using typed or unified search? 

#340871
Oct 30, 2025 20:41

Researched this further and Deepali's answer is correct. This approach works for both UnifiedSearch and typed searches.

I'd probably go with something like this

var langs = new[] { "en-CA", "en-GB"};
var results = _client
    .Search<IContent>()  // or your base type, e.g. SitePageData
    .For(query)
    .FilterForVisitor() 
    .Filter(x => x.Language.In(langs))
    .GetResult();
#340886
Edited, Nov 03, 2025 16:39
* 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.