-
Notifications
You must be signed in to change notification settings - Fork 462
🚸(backend) use unaccented full name for user search #1637
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
33d70ed to
7e5e69b
Compare
|
I think we can also introduce a new index on the User model ? One on the |
Good idea! |
|
It tried to create a GinIndex combined with Unaccent through an OpClass, indexes = [
GinIndex(
OpClass(Func(F("email"), function="unaccent"), name="gin_trgm_ops"),
name="user_email_unaccent_trgm_idx",
),
GinIndex(
OpClass(Func(F("full_name"), function="unaccent"), name="gin_trgm_ops"),
name="user_name_unaccent_trgm_idx",
),
]but apparently it is impossibe because Unaccent is only STABLE, not IMMUTABLE (per this StackOverflow thread) There are a few workarounds but I'm not sure what is the best approach. |
|
🚀 Preview will be available at https://1637-docs.ppr-docs.beta.numerique.gouv.fr/ You can use the existing account with these credentials:
You can also create a new account if you want to. Once this Pull Request is merged, the preview will be destroyed. |
|
Can you squash your commits ? They are all related, you can keep only one. I added the preview label, once your push force made this PR will be available to test. |
a98425a to
2826db8
Compare
|
I added the requested index. For what is worth, I checked the queries through |
44beedc to
d2befee
Compare
We have the user full name through OIDC in the database, but the search only used the email field. This change allows to search for a user by their first and/or last name (fix #929). Given that user names are more likely than emails to include diacritics, it unaccents both the query and the database entry for search (fix #1091). It also unaccents for email so that internationalized domain names are managed whether or not the accent is included in the search. An unaccented gin index is added on users full_name an email fields. Using a manual migration because a wrapper around unaccent is necessary to make it IMMUTABLE (cf. https://stackoverflow.com/questions/9063402/ )
d2befee to
db94bf5
Compare
Purpose
We have the user full name through OIDC in the database, but the search only used the email field.
This change allows to search for a user by their first and/or last name (fix #929).
Given that user names are more likely than emails to include diacritics, it unaccents both the query and the database entry for search (fix #1091). It also unaccents for email so that internationalized domain names are managed whether or not the accent is included in the search.
Proposal
emailandfull_namefields of the User model.External contributions
Thank you for your contribution! 🎉
Please ensure the following items are checked before submitting your pull request:
git commit --signoff(DCO compliance)git commit -S)<gitmoji>(type) title description## [Unreleased]section (if noticeable change)