Friday, January 19, 2018

Sitecore Lucene not returning results for some languages

After expanding a Sitecore 8.1 site to offer content in multiple languages there was a strange error where the search in some languages (pt-BR in particular) would not return any results. This was happening even with a wildcard search that should return all results.

I checked the physical index (using version 3.5 of the Luke tool) and confirmed there were documents indexed with the target language (and these were not opted out of search results).

Luke tool shows the target language indexed.
The original code was using a where clause to filter based on the context language:
.Where(x => x.Language == Sitecore.Context.Language.Name)
Which was not working for some reason, so I tried changing the code to then get results based on culture:
searchItems = context.GetQueryable<SearchResultItem>(new CultureExecutionContext(culture))
After this change the search was returning items in all languages as expected.

No comments:

Post a Comment