PostgreSQL 内置了全文搜索功能——在文档/文本中搜索词语,支持词干提取、相关性排名和语言感知,远比 LIKE 强大。它使用 tsvector(处理后的文档)和 tsquery(搜索查询)这两种类型,并配合 GIN 索引来提升速度。
LIKE 无法解决的问题
LIKE '%word%' → no stemming (won't match "running" for "run"), no ranking, no language
awareness, and can't use an index well (leading wildcard) → slow and limited.
Full-text search → stems words, ignores stop words, ranks by relevance, indexable.
