我正在尝试在包含名称的文本文件上创建三元组索引。我已将 pg_trgm 扩展添加到架构中。运行\dx
显示它已启用:
List of installed extensions
Name | Version | Schema | Description
-----------+---------+------------+-------------------------------------------------------------------
btree_gin | 1.3 | pg_catalog | support for indexing common datatypes in GIN
dblink | 1.2 | wos_core | connect to other PostgreSQL databases from within a database
pg_trgm | 1.4 | wos_core | text similarity measurement and index searching based on trigrams
plpgsql | 1.0 | pg_catalog | PL/pgSQL procedural language
(4 rows)
但是,当我运行以下命令时:
CREATE INDEX authors_full_name_idx ON wos_core.interface_table USING GIN (authors_full_name gin_trgm_ops);
我得到以下信息:
ERROR: operator class "gin_trgm_ops" does not exist for access method "gin"
谁能告诉我我做错了什么?
version
---------------------------------------------------------------------------------------------------------
PostgreSQL 11.2 on x86_64-pc-linux-gnu, compiled by gcc (GCC) 4.8.5 20150623 (Red Hat 4.8.5-36), 64-bit
架构
wos_core
可能不在您的 search_path 中。在这种情况下,您需要在运算符前面加上模式名称:
或者,您可以更改用户的搜索路径,包括
wos_core
:好吧,对我来说,我使用的 postgres 的版本是不同的 - 一旦我升级到更高版本 - 它对我来说很好 - 对于我在执行 db:migrate 时得到的上下文。供参考
我在这里找到了解决方案https://github.com/PostgresApp/PostgresApp/issues/335,在我的情况下,我不得不放弃扩展:
然后我用这个再次创建它: