Skip to content

feat(search): make other searches diacritic insensitive with the unaccent extension#11635

Open
kfc35 wants to merge 2 commits intoopencollective:mainfrom
kfc35:8582_diacritic_insensitive_search
Open

feat(search): make other searches diacritic insensitive with the unaccent extension#11635
kfc35 wants to merge 2 commits intoopencollective:mainfrom
kfc35:8582_diacritic_insensitive_search

Conversation

@kfc35
Copy link
Copy Markdown
Contributor

@kfc35 kfc35 commented Apr 7, 2026

Fixes opencollective/opencollective#8582

  • Adds the unaccent extension in the postgres db, which includes a function that can remove diacritics from strings.
  • Uses the new unaccent function on db fields when they are being filtered with an ILIKE, and prepare search terms with removeDiacritics accordingly
    • In sql-search.ts, buildSearchConditions and buildKyselySearchConditions uses unaccent and removeDiacritics for searching on text fields.
    • As a consequence of this change, for sequelize-based queries built on buildSearchConditions, sequelize.col complains if the column name could be ambiguous. So, I went through all the usages of buildSearchConditions and specified the tables for textFields where necessary (just whenever there was an include clause aka an associated table / join. I figured usages that did not have an include would not have this problem.)
    • There were a one-off query using sequelize and a couple of one-off queries using Kysely that used an ILIKE that I had to manually convert to use unaccent. The fact that these aren’t centralized feels a little off to me personally.

For reviewing, sql-search.ts has the main logic change. CommunityQuery.ts, OrdersCollectionQuery.ts and Host.ts also has new usages of unaccent since they are one-offs. The other changes are due to sequelize.col needing 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 Screenshot 2026-04-06 at 9 43 55 PM Screenshot 2026-04-06 at 9 43 44 PM Screenshot 2026-04-06 at 9 43 34 PM Screenshot 2026-04-06 at 9 43 20 PM Screenshot 2026-04-06 at 9 40 55 PM Screenshot 2026-04-06 at 9 40 41 PM

@kfc35 kfc35 force-pushed the 8582_diacritic_insensitive_search branch 2 times, most recently from 53f4a11 to ab11e9c Compare April 7, 2026 03:09
@kfc35 kfc35 force-pushed the 8582_diacritic_insensitive_search branch from ab11e9c to 87320e7 Compare April 8, 2026 14:31
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Non global searches are sensitive do diatrics

1 participant