When building a search experience for a multilingual audience, it's essential to ensure that users receive results and suggestions in the correct language. This is especially important in countries like Switzerland or Belgium, where multiple languages are spoken.
In this article, we’ll walk through a practical solution for managing multi-language records in Algolia, including how to configure query suggestions so users always see relevant results in their preferred language.
The Use Case
Let’s say your product is available in countries that support multiple languages. For example:
-
Switzerland: French, German, Italian
In this case, we can store all language versions of each product within the same index, and filter at query time based on the user's language.
The Data Structure
Each product is duplicated per language. So if a product is available in English and Italian, for example, it would be indexed twice - once in each language.
[
{
"name": "Borsa",
"description": "Descrizione in italiano",
"language": "it"
},
{
"name": "Bag",
"description": "Description in English",
"language": "en"
}
]
Each record:
-
Is translated in all searchable attributes (like name, description).
-
Contains a language attribute to identify the language.
Yes, this increases the number of records — but since each record is lighter, search performance remains fast.
Filtering Results by Language
To ensure users only see results in their preferred language, add a simple filter when searching:
This guarantees that only Italian results are returned.
You can also tag your queries with the user’s language for analytics tracking:
Query Suggestions
Algolia’s Query Suggestions can also be configured to return results in the correct language.
To do this:
-
Add the
language
as a category attribute when indexing query suggestions. -
The number of categories to show (under
Show top
) must be equal or higher to the number of languages available in the index. This makes sure that suggestions are not excluded by any language: - Apply a language filter at query time:
This ensures that only Italian suggestions are shown when the user is browsing in Italian.