Filter to support Fallback language

Vote:
 

Hi I have the following filter where i have to match the language and category id to get the Articles.

So for example get me all Articles that have en-GB languageBranch and Category ID 20 Or en-GB languageBranch and Category ID 21 and so forth e.t.c.

How can i modify this filter to handle fallback language for example en-AU language branch or other fallback languages? If the Article that doesnt exist in en-GB with Catgegory ID 21 , than return the Article with en-AU and Catgeory ID 21. No matter what i do i get duplicate articles for Catgeory Id 21 (One in en-GB and one in en-AU)

public static ITypeSearch<T> MatchCategories<T>(this ITypeSearch<T> search, string languageBranch, List<int> categories) where T : PageData
{
var taxonomyBuilder = search.Client.BuildFilter<T>();

foreach (var category in categories)
{
taxonomyBuilder = taxonomyBuilder.Or(x => x.LanguageBranch.MatchCaseInsensitive(languageBranch) & x.Category.Match(category));
}

return search.orFilter(taxonomyBuilder);
}

#204974
Jun 24, 2019 14:21
Vote:
 

Hi Rich,

By default Episerver support language fallback if you use the UnifiedSearch.

Please refer this for more info-

https://world.episerver.com/forum/developer-forum/EPiServer-Search/Thread-Container/2015/2/episerver-find/

Thanks

Ravindra

#205005
Edited, Jun 25, 2019 15:24
Vote:
 

Hi Thanks,  i am aware of the thread you shared. My question is doing it through filter as its the requirement of the query i am developing. As you can see from the code its the OrFilter and i have to handle fallback language scenario in the filter.

#205007
Jun 25, 2019 15:36
Vote:
 

Can you not just do:

return search.PublishedInLanguage(languageBranch).OrFilter(taxonomyBuilder) ?

Removing the language branch tests in your filter.

Haven't tested, but should work. 

Thanks,

Paul 

#205011
Edited, Jun 25, 2019 16:31
* 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.