feat(search): make other searches diacritic insensitive with the unaccent extension#11635
Open
kfc35 wants to merge 2 commits intoopencollective:mainfrom
Open
feat(search): make other searches diacritic insensitive with the unaccent extension#11635kfc35 wants to merge 2 commits intoopencollective:mainfrom
unaccent extension#11635kfc35 wants to merge 2 commits intoopencollective:mainfrom
Conversation
53f4a11 to
ab11e9c
Compare
ab11e9c to
87320e7
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes opencollective/opencollective#8582
unaccentextension in the postgres db, which includes a function that can remove diacritics from strings.unaccentfunction on db fields when they are being filtered with anILIKE, and prepare search terms withremoveDiacriticsaccordinglysql-search.ts,buildSearchConditionsandbuildKyselySearchConditionsusesunaccentandremoveDiacriticsfor searching on text fields.sequelize-based queries built onbuildSearchConditions,sequelize.colcomplains if the column name could be ambiguous. So, I went through all the usages ofbuildSearchConditionsand specified the tables fortextFieldswhere necessary (just whenever there was anincludeclause aka an associated table / join. I figured usages that did not have anincludewould not have this problem.)ILIKEthat I had to manually convert to useunaccent. The fact that these aren’t centralized feels a little off to me personally.For reviewing,
sql-search.tshas the main logic change.CommunityQuery.ts,OrdersCollectionQuery.tsandHost.tsalso has new usages ofunaccentsince they are one-offs. The other changes are due tosequelize.colneeding more specific column references.I think I got all the relevant places where there is search, but given my unfamiliarity with the whole codebase, I wouldn’t be surprised if I missed some. As a caveat, I also haven’t thought about performance at all while implementing this.
Screenshots of various pages with diacritic insensitive search