21 Nov 2018

Multilingual Search


By design the Algolia engine is language agnostic. Out of the box, it supports all languages / alphabets, including symbol based languages such as Chinese, Japanese and Korean.

Additionally, Algolia handles multi-languages on the same website/app, meaning some users could search in French, and some in English, using the same Algolia account on the background.

The purpose of this guide is to explain how to organize your indices to enable multi-language search.

The best solution for your use-case

There are different ways to handle multiple languages in search. To determine the best solution for you, answer the following questions:

1. Does the ranking need to be different for each language?

There are a couple of reasons the ranking might need to change depending on the language:

  • The price is not the same in different countries (and you want to sort by price)
  • The object doesn’t have the same popularity in all regions of the world (and you have popularities scores per region)

2. If you put all languages in one record, will the records be bigger than 10kb?

Algolia limits record size to a maximum size of 10kb.

If you have multiple languages, you may need to insert a lot of text in your records. It’s important to determine if your records will end up being bigger than 10kb.

Pick your solution

If either one of the following is true

  • You have a different ranking strategy depending on the language
  • If you put all languages in the same record, the size of the record would be bigger than 10kb

Then the only solution is to create one index per language. Otherwise, go with one index where each record contains all languages.

Option 1: One index per language

In this solution, you need to create one index per language:

// Index movies_eng
  "objectID": 1,
  "title": "The Wolf of Wall Street",
}, // …
// Index movies_fr
  "objectID": 1,
  "title": "Le loup de Wall Street",
}, // …
// Index movies_es
  "objectID": 1,
  "title": "El lobo de Wall Street",
}, // …

Once your records are indexed in the different indices, you now need to decide, on the front-end, which index to target.

Option 2: Each record contains all languages

In this solution, you’ll create one index containing all languages. Your records will look like this:

// Index movies
  "objectID": 1,
  "title_eng": "The Wolf of Wall Street",
  "title_fr": "Le loup de Wall Street",
  "title_es": "El lobo de Wall Street"
// …

What you now need to do is to set the attributes from all languages searchable, using searchableAttributes.

$client->initIndex("movies")->setSettings(array("searchableAttributes" => array("title_eng,title_fr,title_es")));
Algolia.init_index('movies').set_settings({ searchableAttributes: ['title_eng,title_fr,title_es'] })
client.initIndex('movies').setSettings(new IndexSettings().setSearchableAttributes(Arrays.asList("title_eng", "title_fr", "title_es")));
res, err := client.InitIndex("movies").SetSettings(algoliasearch.Map{
    "searchableAttributes": []string{"title_eng", "title_fr", "title_es"},
val result: Future[Task] = client.execute {
  changeSettings of "myIndex" `with` IndexSettings(
    searchableAttributes = Some(Seq(AttributesToIndex.attributes("title_eng", "title_fr", "title_es"))),
client.initIndex('movies').setSettings({searchableAttributes: "title_eng,title_fr,title_es"]});

Then at query time you’ll need to specify which attributes you want searchable, depending on the language of the user. Here’s how to accomplish this using Algolia’s Javascript Helper:

// Search only in the French title

What’s next

Continue building your Algolia knowledge with these tutorials:

© Algolia - Privacy Policy