我试图创建查询以在我的sql数据库中找到名称other
。我有一个基本的类似搜索如下,并想使用全文搜索。
类似查询
SELECT g.*, COUNT(*) OVER() AS total
FROM group AS g
WHERE UPPER(g.name) LIKE UPPER('oth%')
全文查询
SELECT g.*, COUNT(*) OVER() AS total
FROM group AS g
WHERE to_tsvector(g.name) @@ to_tsquery('oth:*')
似乎我的全文返回0,这与我喜欢的搜索不同。为什么这样,当两个查询似乎都在执行类似的搜索时
在英语的默认停用词列表中看起来像“其他”。我已经在Linux级别使用PostgreSQL 12进行了测试:
$ grep other /usr/pgsql-12/share/tsearch_data/english.stop
other
在数据库中:
postgres=# select to_tsvector('french','other');
to_tsvector
-------------
'other':1
(1 row)
postgres=# select to_tsvector('english','other');
to_tsvector
-------------
(1 row)
postgres=# select to_tsvector('english','others');
to_tsvector
-------------
'other':1
(1 row)
postgres=# select to_tsvector('english','another');
to_tsvector
-------------
'anoth':1
(1 row)
尝试“另一个”。