Gravatar for

Question by DEEPTHI KATTA, Jul 12, 2018 9:55 PM

Get fall back language item when language specific version is not available

Hi There!

We have a special requirement where on search results page when a query is fired or on coveo search page load :

1. We want to capture and display context specific language and culture items when available

2. If language specific version is not available, we would like to pull in fall back language item

Basically, we need to always pull items from Coveo Index that are either context language or fall back language. I realize this could be done with some meddling on advanced expression to query and get both languages in question that match query. But, we would like to avoid duplicates in case where a specific item contains both context language version and also contains fall back version.

Is there a way to achieve this with out duplicates?

Gravatar for

Comment by DEEPTHI KATTA, Jul 13, 2018 5:19 AM

Strike of thought! if I flatten my problem in to a set problem ignoring all other surrounding details at this time. Imagine two sets of results based on points #1 and #2 above. Now essentially, I would like everything in set #1 to display in results and now from second set I only want negation {2}-{1} to ensure I do not have duplicates.

Now, how do I do that. While indexing a fall back item (any fall language item that belongs to say en language), what i would then do is set up a special field that carries simple list of language/culture versions the current database has excluding the en one.

Now, my advanced expression would become -

(language = context language) || (language = fallback language && existing versions does not contain conext language)

This would then give me what I am looking for minus duplicates. One thing I might have to do is add fall back version of item as related item when any other language item is being synced to ensure this field of mine is up to date when say a new language version is added or removed.

I think this might work. :) Any thoughts?. Also, I am curious now on the actual glue of Sitecore on different language versions of same content item. May be Sitecore already ties these together some how, so, negation might become easier if there was a field to know if this item has other language versions I am interested in.

1 Reply
Gravatar for

Answer by Jean-François L'Heureux, Jul 13, 2018 11:11 AM

Hi Deepthi,

I think you are over engineering the solution here. Coveo indices in Sitecore do support language fallback out of the box with 2 settings you can find in the index element configuration:

<index id="Coveo_master_index" ...>

As you can see, it is disabled by default.

Let's say you have 5 languages total.

By enabling at least the `enableItemLanguageFallback` option, Coveo will index all items 5 times. Once per language even if there is no version for a given language for an item. The data in this item will be the data of the configured fallback language. However, I believe that the `_language` field value will be the language with no item version.

That way, you can just enable the language filtering option on your Coveo Search Interface component and Coveo will automatically return results in the user language and the fallback items when needed.

Gravatar for

Comment by DEEPTHI KATTA, Jul 13, 2018 2:26 PM

Hi Jeff,

We did enable both item and field fall back. But, I did notice that Coveo is only indexing versions that exist on the content item. For example, say a content item has japan, Chinese and en then I see only those versions on index with fall back set to true. I do not see other language versions that sitecore instance is set up to have but do not exist in the content for a given item.

Let me check this again today, but, if this is the case then I think we should be good. All we need is that, return language version when existing if not there then return fall back version.

In case if Coveo is not for some reason pushing all languages even if item fall back is enabled then we have a problem.

Ask a question