If you need to "combine with case insensitive", there are a number of options, depending on your exact requirements.
Maybe simplest, make the expression index case insensitive.
Building on the function f_unaccent()
laid out in the referenced answer:
CREATE INDEX users_lower_unaccent_name_idx ON users(lower(f_unaccent(name)));
Then:
SELECT *
FROM users
WHERE lower(f_unaccent(name)) = lower(f_unaccent('Jo?o'));
Or you could build the lower()
into the function f_unaccent()
, to derive something like f_lower_unaccent()
.
Or (especially if you need to do fuzzy pattern matching anyways) you can use a trigram index provided by the additional module pg_trgm building on above function, which also supports ILIKE
. Details:
I added a note to the referenced answer.
Or you could use the additional module citext:
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…