withSearchIndex with diacritical signs
Hello,
Context:
I am working on a feature to search users by name within my app.
Problem:
However I noticed that if I don't type diacritical signs that are present on some user names, they do not appear in my search.
For instance, one of my user is called:
Adélaïde
. If I look for Adelaide
, the withSearchIndex
function won't return that user.
Overall after some testing, I believe that diacritical signs are considered as a totally different letter with the current searchIndex.
Request:
I think letters without diacritical signs should be considered close to the original letter. Not sure if it's easily feasible on your side and if you are able to introduce a ponderation somehow (instead of a YES/NO).
Thanks and have a nice day!4 Replies
I handle this by writing a duplicate string into the db without the diacritics, and then when search I also transform the string using the same function:
https://github.com/xixixao/saas-starter/blob/main/convex/utils.ts#L17-L19
GitHub
saas-starter/convex/utils.ts at main · xixixao/saas-starter
Convex, Clerk, Next.js, Convex Ents. Contribute to xixixao/saas-starter development by creating an account on GitHub.
Taken from here: https://stackoverflow.com/a/23633850/1526986
Stack Overflow
Convert non-ASCII characters (umlauts, accents...) to their closest...
I am looking for way in JavaScript to convert non-ASCII characters in a string to their closest equivalent, similarly to what the PHP iconv function does. For instance if the input string is Rånade...
In the example you can see I also combine the member's email and full name into one field that I can then search by.
Wow, that is very interesting, I didn't event know something like this directly existed in the language.
Thanks for your help @Michal Srb 🙏