I18n searching

I have a web app that has to be i18n enabled on the client. So, for example, this app is used in both US and Mexico. Someone from mexico uses this app and posts the word "salchicha" in the field called 'title'. So for someone in the US trying to do a search for "sausage" in the title, obviously won't get any hits. I think the recommended approach is to index the word twice in the same 'title' field, one for salchicha and the other for sausage, so that hits will show up for both words. If this is the correct approach, how can one scale to other languages-- say I wanted to add french and portuguese later? Was wondering if there was a standard approach to handling multiple languages for the same field, maybe a language filter that takes a word and language type, and does an english translation, before doing a search?


I did not found a solution either, and I ended up with using a different type for every language.

If you have an object in frontend or stored in your real database like this:

{ id : xxx, title : { de_DE : 'Das fooBar', fr_FR: 'Le fooBar' } }

it would be stored as two documents in elastic, one for "de_DE" in:
{ title : 'Das fooBar' }

and one for 'fr_FR' in:
{ title : 'Le fooBar'' }

If you want to search now in German you would query "/indexName/de_DE" and for french "/indexName/fr_FR". This way you are free to manage as many languages as you want.

At least this is what I came up with, dont know if it's "the way" but I guess it works pretty good :slight_smile:

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.