查询
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)
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,' ')) );
(可能会以更优雅的方式形成茎的阵列.)
原文地址:https://www.jb51.cc/postgresql/191728.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。