When you generate your data in DB you save both strings. I see a couple of cases:
You only need to save names (of people, places etc) where in most cases the string is 1-2 words.
const transName = name.normalize('NFD').replace(/\p{Diacritic}/gu, '')
// trans is for transliterated (or normalized)
{
name: 'String',
transName: 'String'
}
You have the ascii word as part of a longer text. In this case you can test the string for diacritics and if you have a word with diacritics, that you know you will want to search for you can just extract it/them (I mean copy, push to) into an array, in its transliterated form.
In both cases you do the search for the transliterated word. You normalize the search word before you query the DB and you search in the fields that contain the normalized version of the word.
Ok, I’ve been reading about indexes in Mongo and found this. Look for index collation.
" By specifying a collation strength of 1 or 2 , you can create a case-insensitive index. Index with a collation strength of 1 is both diacritic- and case-insensitive."