First of all - I use JPA ORM (EclipseLink) which doesn't support ILIKE. So I am looking for solution to have case insensitive search. I did the following:
CREATE TABLE IF NOT EXISTS users (
id SERIAL NOT NULL,
name VARCHAR(512) NOT NULL,
PRIMARY KEY (id));
CREATE INDEX users_name_idx ON users USING gin (LOWER(name) gin_trgm_ops);
INSERT INTO users (name) VALUES ('User Full Name');
However, this query returns user:
SELECT * FROM users WHERE name ILIKE '%full%';
But this one doesn't:
SELECT * FROM users WHERE name LIKE '%full%';
So, how to create GIN index with LOWER in PostgreSQL?