Try our conversational search powered by Generative AI!

How to define a conditional query filter for language?


I need to filter a page type by the current language and if it is not available then filter by 'en'. 

I tried this, but it returns both current language and 'en' instances. 

languageFilter.Or(x => x.LanguageID.MatchCaseInsensitive(currentLang) | (!x.LanguageID.MatchCaseInsensitive(currentLang) & x.LanguageID.MatchCaseInsensitive("en")));

I need 'en' content only if current langage instance is not available. 

Can I define such a query filter ?

Oct 15, 2015 6:55

Try using the "PageLanguages" property instead of the LanguageID.

Oct 16, 2015 13:44

If only the "PageLanguages" property was matched, it only shows the pages of current language.

But I want to retrieve EN pages if there's no language branch in current language. 

I tried this but it doesn't work. 

languageFilter = languageFilter.Or(x => x.PageLanguages.Match(languageId) & x.LanguageID.MatchCaseInsensitive(languageId));
languageFilter = languageFilter.Or(x => !x.PageLanguages.Match(languageId) & x.LanguageID.MatchCaseInsensitive("en"));

Oct 19, 2015 11:55
* 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.