postgresql – Postgres引发匹配

查询

SELECT to_tsvector(‘entertainment’)@@ to_tsquery(‘recreatio:*’);

即使“recreati”是“娱乐”的前缀,也返回false.这似乎是因为“娱乐”被储存为它的干,“重新”.例如,如果我们通过运行故意破坏干扰算法

SELECT to_tsvector(‘entertainment1’)@@ to_tsquery(‘recreatio:*’);

查询返回true.

有没有办法使第一个查询匹配?

不确定这个答案是否有用,因为问题的年龄,但是:

关于遏制

看来你是对的:

select ts_lexize('english_stem','recreation');

输出

ts_lexize
-----------
 {recreat}
(1 row)

documentation

Also,* can be attached to a lexeme to specify prefix matching:

SELECT to_tsquery('supern:*A & star:A*B');

Such a lexeme will match any word in a tsvector that begins with the given string.

所以似乎没有办法使原始查询匹配.

基于部分匹配的解决方

人们可能会回头寻找茎和查询的部分匹配,例如.使用pg_trgm扩展名

SELECT (to_tsvector('recreation creation') @@ to_tsquery('recreatio:*')) or 
  'recreatio:*' % any (
    select trim(both '''' from regexp_split_to_table(strip(to_tsvector('recreation creation'))::text,' '))
  );

(可能会以更优雅的方式形成茎的阵列.)

相关文章

项目需要,有个数据需要导入,拿到手一开始以为是mysql,结果...
本文小编为大家详细介绍“怎么查看PostgreSQL数据库中所有表...
错误现象问题原因这是在远程连接时pg_hba.conf文件没有配置正...
因本地资源有限,在公共测试环境搭建了PGsql环境,从数据库本...
wamp 环境 这个提示就是说你的版本低于10了。 先打印ph...
psycopg2.OperationalError: SSL SYSCALL error: EOF detect...