Try our conversational search powered by Generative AI!

EPiServer Find

Vote:
 

Hi,

Does EPiServer Find support fallback languages / replacement languages?

#118043
Feb 26, 2015 13:01
Vote:
 

Hi,

Yes, Find supports fallback/replacement languages by default when using UnifiedSearch. If you issue a custom typed query you can use the .PublishedInLanguage(language) (EPiServer.Find.Cms-namespace) extension to filter out content following fallback/replacement rules.

/Henrik

#118187
Mar 02, 2015 12:38
Vote:
 

Hello,

I struggle a bit with the language fallback logic in Find and his extensions.

Search client supports indeed fallback, but when you use GetPagesResult() and the page does not exists in the requested language, you'll get nothing. Because this extensions filters the result for the requested language. Correct?

Workaround, I use GetResult and use the page reference to load the page with IContentRepository with fallback enabled.

var result = _searchClient.Search<T>()
.ExcludeDeleted()
.PublishedInCurrentLanguage()
.Select(x => new PageReference(x.PageLink.ID, x.PageLink.ProviderName))
.GetResult();

where T : PageData

Also doesn't work, no hists. PublishedInCurrentLanguage() doesn't seems to enable fallback in this scenario.

But it does work in the following query:

var searchResult = _searchClient.Search<ICanBeSearched>()
.For(searchText)
.PublishedInCurrentLanguage()
.ExcludeDeleted()
.Take(searchPage.NumberOfSearchResultsToShow)
.Select(x => new GenericSearchResult()
{
Title = x.Title,
Summary = x.Summary,
Image = x.Image,
ContentReference = x.ContentLink
})
.GetResult();

There seems to be a difference how language fallback is handled in these 2 scenario's.

Final workaround:

var result = _searchClient.Search<T>()
.ExcludeDeleted()
.Select(x => new PageReference(x.PageLink.ID, x.PageLink.ProviderName))
.GetResult();

if (result.TotalMatching > 1) throw new Exception($"More than 1 page found of type '{nameof(T)}'.");

var pageReference = result.Hits.First().Document;

return _contentRepository.Get<T>(pageReference, new LoaderOptions() { LanguageLoaderOption.FallbackWithMaster(_userContext.CurrentLanguage) });

Someone an idea where it goes wrong?

Many thanks,

bob

#180619
Jul 17, 2017 16:51
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.