0

I have a site with the language english (en -> default language) and portuguese (pt-BR). Now I have the problem that on the portugese website there are shown items of the english language version. The items are in the solr index. Sitecore version: 9.3

This is the code which starts the search:

        string indexName = "list_item_search_index_" + Sitecore.Context.Database.Name;
        List<ListSearchResult> result = SearchManager.ContentSearch(searchword, indexName, expr, true);

This is the config for Sitecore.Solr.SearchIndexes.config:

      <index id="list_item_search_index_master" type="Sitecore.ContentSearch.SolrProvider.SolrSearchIndex, Sitecore.ContentSearch.SolrProvider">
        //other configs
        <enableItemLanguageFallback>true</enableItemLanguageFallback>
        <enableFieldLanguageFallback>true</enableFieldLanguageFallback>
      </index>

I already enabled languagefallback for this index and rebuilt the index. It is still showing the false language version. I tried it with the master database.

8
  • When you look at the raw solr query, what language do you see being queried? Feb 11, 2021 at 14:03
  • Add language filter to your search predicates might help Feb 11, 2021 at 17:31
  • You can do a filter by language like this .Filter(x => x.Language == Context.Language.Name) if you are using an IQueryable type Feb 11, 2021 at 18:27
  • Post the code of SearchManager.ContentSearch method
    – Marek Musielak
    Feb 12, 2021 at 7:13
  • There are two languages that are indexed. Once the "en" and once pt-BR in the raw index of solr.
    – dave_26456
    Feb 16, 2021 at 8:09

2 Answers 2

1

In your case I would maybe check whether you don't have any ComputedFields. This is usually causing trouble as language fallback is not applied of course automatically for these fields.

I assume that the current code is missing getting field value based on language so something like this: item.Database.GetItem(indexableItem.itemid)

You need to add second parameter and provide also language/culture so something like this: item.Database.GetItem(indexableItem.itemid, Sitecore.Globalization.Language.Parse(indexableItem.Culture.Name))

1
  • This was exactly the problem. Thank you!
    – dave_26456
    Apr 1, 2021 at 11:15
1

It sounds like you don't need the Language fallback enabled in the first place.

Items with language fallback enabled and don't have the pt-BR version, Sitecore will use the fallback language (in this case I believe en) for indexing. If you don't want this to happen, you could turn it off.

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.