Introduction
In the previous topic I mentioned that we have some operators for the pattern matching (LIKE (~~), ILIKE (~~*), ~, ~* and SIMILAR TO) and an operator for the text search (@@). If you know exactly what you want to find this operators are good choise.
But if you know a search query only approximately then a trigram matching can help you. A trigram matching is provided by the pg_trgm module in PostgreSQL. For example, you can execute the following query:
CREATE TABLE clients(name varchar); INSERT INTO clients VALUES('Devereaux'), ('Devereux'); SELECT * FROM clients WHERE name % 'Devereux';
And you will get the following people with the Devereux surname:
name ----------- Devereaux Devereux (2 rows)