Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/postgresql/9.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Sql Postgres喜欢全文搜索_Sql_Postgresql_Postgresql 9.4_Postgresql 9.5 - Fatal编程技术网

Sql Postgres喜欢全文搜索

Sql Postgres喜欢全文搜索,sql,postgresql,postgresql-9.4,postgresql-9.5,Sql,Postgresql,Postgresql 9.4,Postgresql 9.5,我正在尝试创建一个查询,以在我的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_

我正在尝试创建一个查询,以在我的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)
试试“另一个”