November Happy Hour will be moved to Thursday December 5th.
November Happy Hour will be moved to Thursday December 5th.
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
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
Hi,
Does EPiServer Find support fallback languages / replacement languages?