Get fall back language item when language specific version is not available
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?
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" ...> <enableItemLanguageFallback>false</enableItemLanguageFallback> <enableFieldLanguageFallback>false</enableFieldLanguageFallback> </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.