pg_bigm 中文支持 比 pg_trgm 要好,pg_trgm 在 Mac osx 中不支持中文等 Unicode 字符,原因如下:
The pg_bigm module provides full text search capability in PostgreSQL. This module allows a user to create 2-gram (bigram) index for faster full text search.
pg_bigm is released under the PostgreSQL License, a liberal Open Source license, similar to the BSD or MIT licenses.
For more information look at the official pg_bigm web site.
make USE_PGXS=1 PG_CONFIG=`which pg_config` install
# sudo -u postgres psql
# \c dbname
create extension pg_bigm
select show_bigm('做软件的禅师')
# 相似度 0.71428573
select bigm_similarity('哇!故宫的二十四节气-芒种', '芒种-哇!故宫的二十四节气');