如何使用扩展名pg_trgm中的%运算符? [英] How to use % operator from the extension pg_trgm?
本文介绍了如何使用扩展名pg_trgm中的%运算符?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我已经安装了 pg_trgm
模块。
pg_trgm | 1.0 | extensions | text similarity measurement and index ...
模式集为扩展名
。要使用它,我必须运行以下选择:
The schema set is extensions
. To use it I have to run something like this select:
extensions.similarity('hello','hallo');
我正在尝试使用%$ c来运行语句$ c>运算符,并收到以下消息。
I'm trying to run a statement using the %
operator and got the following message.
mydb=# select * from rssdata where description % 'Brazil';
ERROR: operator does not exist: character varying % unknown
LINE 1: select * from rssdata where description % 'Brazil';
^
HINT: No operator matches the given name and argument type(s).
You might need to add explicit type casts.
运行%
或<->
运算符?
推荐答案
最有可能是一个问题与 search_path
。运行:
Most probably this is a problem with the search_path
. Run:
SHOW search_path;
是您安装的架构 pg_trgm 包括在内吗?如果没有,则将其包括在内。
Is the schema where you installed pg_trgm included? If not, include it.
或者,您可以使用模式限定功能-甚至使用 OPERATOR()
构造:
Alternatively, you can schema-qualify functions - and even operators using the OPERATOR()
construct:
SELECT * FROM rssdata WHERE extensions.similarity(description, 'Brazil') > .8;
SELECT * FROM rssdata WHERE description OPERATOR(extensions.%) 'Brazil';
使其独立于 search_path
。
这篇关于如何使用扩展名pg_trgm中的%运算符?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文