I'm trying to develop a trigram search using pg_trgm PostgeSQL extension. The search should be case insensitive and ignore accents in Slovak language. I've tried to achieve this by creating a custom ICU collation, with collation level 1, which I thought would ignore the accents.

CREATE COLLATION "sk-for-search" (provider = icu, locale = 'sk-u-kn-true-ks-level1', deterministic = false);

This is not working for me well in practice. Some accents are ignored, but others not.

SELECT 'a' = 'á' COLLATE "sk-for-search"; -- RETURNS true ✅
SELECT 'z' = 'ž' COLLATE "sk-for-search"; -- RETURNS false ❌

Why is my collation not ignoring the accent on ž? Is there a way to create a PostgreSQL collation that ignores all accents?

  • 2
    Note that 'z' = 'ž' is true at primary level (ks-level1) for some other (non-slovak) languages. So whatever is the reason, it seems language-related. und in place of a language code can be used for language-agnostic collations. Apr 1 at 18:59


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.