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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/django/24.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 如何使用扩展pg_trgm中的%运算符?_Sql_Postgresql_Pattern Matching_Search Path - Fatal编程技术网

Sql 如何使用扩展pg_trgm中的%运算符?

Sql 如何使用扩展pg_trgm中的%运算符?,sql,postgresql,pattern-matching,search-path,Sql,Postgresql,Pattern Matching,Search Path,我安装了pg\u trgm模块 pg_trgm | 1.0 | extensions | text similarity measurement and index ... 架构集是extensions。要使用它,我必须运行如下选择: extensions.similarity('hello','hallo'); 我正在尝试使用%运算符运行语句,并收到以下消息 mydb=# select * from rssdata where description % 'Brazil'; ERR

我安装了
pg\u trgm
模块

pg_trgm | 1.0     | extensions | text similarity measurement and index ...
架构集是
extensions
。要使用它,我必须运行如下选择:

extensions.similarity('hello','hallo');
我正在尝试使用
%
运算符运行语句,并收到以下消息

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. 

运行
%
操作符需要什么?

这很可能是操作系统的问题。运行:

是否包括您安装的架构?如果没有,请包括在内

或者,您可以使用以下命令对函数甚至运算符进行模式限定:


使其独立于
搜索路径

谢谢。我把它改成了pg_目录。更改扩展pg_trgm集合模式pg_目录;看起来很有效。@user3491961:但是
pg_catalog
是个坏主意。这应该为系统对象保留。将扩展安装到
公共
架构或专用的
扩展
架构,并确保在搜索路径中包含该架构。不要滥用PGU目录!谢谢昨天开始学习Postgresql。谢谢。在架构内创建扩展:
create EXTENSION IF NOT EXISTS btree\u gin WITH schema extensions
如果不存在带有模式扩展的pg_trgm,则创建扩展应在此之后工作
SHOW search_path;
SELECT * FROM rssdata WHERE extensions.similarity(description, 'Brazil') > .8;
SELECT * FROM rssdata WHERE description OPERATOR(extensions.%) 'Brazil';