Better than LIKE
ILIKE '%momo%' can't find "momos" when you search "momo", can't rank results, and can't use a normal index. PostgreSQL's full-text search understands words ("steaming" matches "steamed"), ranks matches, and is fast with a GIN index — no extra search server needed for many apps.
tsvector, tsquery, @@ and ts_rank
CREATE TABLE recipes (
id int GENERATED ALWAYS AS IDENTITY PRIMARY KEY,
title text NOT NULL,
body text NOT NULL,
search tsvector GENERATED ALWAYS AS (
setweight(to_tsvector('english', title), 'A') || setweight(to_tsvector('english', body), 'B')
) STORED
);
CREATE INDEX recipes_search_idx ON recipes USING gin (search);
INSERT INTO recipes (title, body) VALUES
('Steamed momos', 'Fold the dumplings and steam them for twelve minutes.'),
('Spicy achar', 'Roast tomatoes and chillies, then grind with garlic. Great with momo.'),
('Masala tea', 'Boil tea leaves with milk, ginger and cardamom.');
SELECT to_tsvector('english', 'Steaming the dumplings');
SELECT title, ts_rank(search, query) AS rank
FROM recipes, websearch_to_tsquery('english', 'momo') AS query
WHERE search @@ query
ORDER BY rank DESC;