Multilingual search - One index per language #

Adapting the example for single index multiple language search for our usecase, I ran into an issue with the code examples provided using restrictSearchableAttributes:

Is it correct that the example code provided does not work as intended, or am I missing something here?

@phoet welcome to the community!

Which language are you using and seeing this issue? I can take a look and see if the documentation needs to be updated.

Or are you getting an error response from the Algolia API?

Happy to help further, thanks!

i checked in javascript and ruby, but the error comes from the algolia api, so i assume it’s not an issue with one of the libraries. the user in the linked issue was using PHP.

as far as i understand, creating an index with a list of unordered (virtual) attributes on the same level

  searchableAttributes: ["title_eng,title_fr,title_es"]

is incompatible with restricting attributes of only one of the attributes:

// search only in the French titles'wolf', {
  'restrictSearchableAttributes': 'title_fr'
}).then(({ hits }) => {

it would have to be 'restrictSearchableAttributes': 'title_eng,title_fr,title_es' which does not makes sense because you just want to search in one of the fields. so i guess the index needs to be created differently searchableAttributes: ["title_eng", "title_fr", "title_es"], which in turn would change the priority of ordered fields…

@phoet gotcha!

Yeah, this code sample needs to separate out the searchableAttributes. Once you do this, the code snippet works as intended. I will submit a request to have this updated. Thank you for pointing this out!

await index.setSettings({
    searchableAttributes: ["title_fr", "title_eng", "title_es"]

// search only in the French titles'loup', {
    restrictSearchableAttributes: 'title_fr'
    .then(({ hits }) => { console.log(hits); })
    .catch(err => { console.error(err) })