为什么这个全文搜索在 PostgreSQL 中不匹配?

Why Doesn't This Full Text Search Match in PostgreSQL?

我正在评估 PostgreSQL,看看它是否是 ElasticSearch 的可行替代方案(稍后迁移很好)。我一直在阅读 PG 全文能力现在 'good enough'。我是 运行 版本 11。

为什么这检测不到匹配项?我认为词干提取很容易检测到单词 "big":

的不同形式
SELECT to_tsvector('english', 'bigger') @@ to_tsquery('english', 'big')

我使用的配置有误吗?

看来我需要安装 ispell 词典,因为默认情况下英语词典不会这样做。

https://www.postgresql.org/docs/current/textsearch-dictionaries.html#TEXTSEARCH-ISPELL-DICTIONARY

另请参阅此答案:

您还可以重复使用 english.shenglish.sql 来自 https://dba.stackexchange.com/questions/57058/how-do-i-use-an-ispell-dictionary-with-postgres-text-search 的脚本。

我在生成的词典里修改了: 在 english.affix 我添加了 IG > GER 规则:

flag *R:
    E           >       R               # As in skate > skater
    [^AEIOU]Y   >       -Y,IER          # As in multiply > multiplier
    [AEIOU]Y    >       ER              # As in convey > conveyer
    [^EY]       >       ER              # As in build > builder
    IG          >       GER             # For big > bigger

english.dict我修改了

big/PY

big/PYR

运行english.sql后为当前数据库(需要在脚本中修改数据库名称):

postgres=# select ts_debug('english bigger');
select ts_debug('english bigger');
                                              ts_debug                                              
----------------------------------------------------------------------------------------------------
 (asciiword,"Word, all ASCII",english,"{english_ispell,english_stem}",english_ispell,{english})
 (blank,"Space symbols"," ",{},,)
 (asciiword,"Word, all ASCII",bigger,"{english_ispell,english_stem}",english_ispell,"{bigger,big}")
(3 rows)

postgres=# SELECT to_tsvector('english bigger') @@ to_tsquery('english', 'big');
SELECT to_tsvector('english bigger') @@ to_tsquery('english', 'big');
 ?column? 
----------
 t
(1 row)