我在postgresql文档后面的PostgreSQL服务器9.3.5上创建了一个文本搜索配置:
CREATE TEXT SEARCH CONFIGURATION french_noaccent ( COPY = french );
ALTER TEXT SEARCH CONFIGURATION french_noaccent ALTER MAPPING FOR hword, hword_part, word WITH unaccent, french_stem;
我已经使用它已经是我的Django项目数据库了,可以使用\ dF看到它:
Schéma | Nom | Description
------------+------------------+---------------------------------------
pg_catalog | danish | configuration for danish language
pg_catalog | dutch | configuration for dutch language
pg_catalog | english | configuration for english language
pg_catalog | finnish | configuration for finnish language
pg_catalog | french | configuration for french language
pg_catalog | german | configuration for german language
pg_catalog | hungarian | configuration for hungarian language
pg_catalog | italian | configuration for italian language
pg_catalog | norwegian | configuration for norwegian language
pg_catalog | portuguese | configuration for portuguese language
pg_catalog | romanian | configuration for romanian language
pg_catalog | russian | configuration for russian language
pg_catalog | simple | simple configuration
pg_catalog | spanish | configuration for spanish language
pg_catalog | swedish | configuration for swedish language
pg_catalog | turkish | configuration for turkish language
public | french_noaccent |
public | spanish_noaccent |
然而,当我尝试在另一个项目数据库(仍然在同一台服务器上)上使用它时,我收到此错误
text search configuration "public.french_noaccent" does not exist
LINE 1: ...rank_cd(watson_searchentry.search_tsv, to_tsquery('public.fr...
(抱歉,我不知道如何获得完整的LINE:/)
有人知道为什么会这样,以及如何在第二个数据库上提供我的文本搜索配置?
非常感谢
编辑(感谢@doru):我使用root帐户创建了文本搜索配置,但我的项目数据库有自定义所有者,当我使用\ dF与此帐户时,我无法在列表中看到它们。我试过了
ALTER TEXT SEARCH CONFIGURATION french_noaccent OWNER TO myuser;
但仍然无法看到它们。所以我尝试使用自定义帐户:
myuser=> CREATE TEXT SEARCH CONFIGURATION french_noaccenttst ( COPY = french );
CREATE TEXT SEARCH CONFIGURATION
myuser=> ALTER TEXT SEARCH CONFIGURATION french_noaccenttst ALTER MAPPING FOR hword, hword_part, word WITH unaccent, french_stem;
ERROR: text search dictionary "unaccent" does not exist
所以我想我现在的问题是如何让我的用户可以使用非语言词典?
答案 0 :(得分:2)
好的,所以我终于让它工作了,并且认为我可以解释原因。
在某些时候,我使用 \ dn +
检查了我的用户在我的数据库上的权限在第一个(工作正常的那个)我有:
Liste des schémas
Nom | Propriétaire | Droits d'accès | Description
public | myuser | root=UC/root +
=UC/root | standard public schema
和第二个(没有工作)
Liste des schémas
Nom | Propriétaire | Droits d'accès | Description
public | myuser | | standard public schema
因此,我使用myuser:
授予对root的公共模式的访问权限以匹配第一个配置myuser=> grant usage on schema public to root;
myuser=> grant create on schema public to root;
Liste des schémas
Nom | Propriétaire | Droits d'accès | Description
public | myuser | myuser=UC/myuser +|standard public schema
root=UC/myuser |
不完全一样,但它应该可行,我的文本搜索配置仍然不能用于 \ dF ,但是让我们看看unaccent模块是否可用 \ DFD 强>
Liste des dictionnaires de la recherche de texte
Schéma | Nom | Description
------------+-----------------+-----------------------------------------------------------
pg_catalog | danish_stem | snowball stemmer for danish language
pg_catalog | dutch_stem | snowball stemmer for dutch language
pg_catalog | english_stem | snowball stemmer for english language
pg_catalog | finnish_stem | snowball stemmer for finnish language
pg_catalog | french_stem | snowball stemmer for french language
pg_catalog | german_stem | snowball stemmer for german language
pg_catalog | hungarian_stem | snowball stemmer for hungarian language
pg_catalog | italian_stem | snowball stemmer for italian language
pg_catalog | norwegian_stem | snowball stemmer for norwegian language
pg_catalog | portuguese_stem | snowball stemmer for portuguese language
pg_catalog | romanian_stem | snowball stemmer for romanian language
pg_catalog | russian_stem | snowball stemmer for russian language
pg_catalog | simple | simple dictionary: just lower case and check for stopword
pg_catalog | spanish_stem | snowball stemmer for spanish language
pg_catalog | swedish_stem | snowball stemmer for swedish language
pg_catalog | turkish_stem | snowball stemmer for turkish language
public | unaccent |
所以我使用我的初始帖子的前2个命令重新创建了我的文本搜索配置,只是这次我使用我的buggy数据库上的myuser帐户做了
myuser=> CREATE TEXT SEARCH CONFIGURATION french_noaccenttst ( COPY = french );
myuser=> ALTER TEXT SEARCH CONFIGURATION french_noaccenttst ALTER MAPPING FOR hword, hword_part, word WITH unaccent, french_stem;
这次它运作得很好,并且出现在 \ dF
中 Liste des configurations de la recherche de texte
Schéma | Nom | Description
------------+------------------+---------------------------------------
pg_catalog | danish | configuration for danish language
pg_catalog | dutch | configuration for dutch language
pg_catalog | english | configuration for english language
pg_catalog | finnish | configuration for finnish language
pg_catalog | french | configuration for french language
pg_catalog | german | configuration for german language
pg_catalog | hungarian | configuration for hungarian language
pg_catalog | italian | configuration for italian language
pg_catalog | norwegian | configuration for norwegian language
pg_catalog | portuguese | configuration for portuguese language
pg_catalog | romanian | configuration for romanian language
pg_catalog | russian | configuration for russian language
pg_catalog | simple | simple configuration
pg_catalog | spanish | configuration for spanish language
pg_catalog | swedish | configuration for swedish language
pg_catalog | turkish | configuration for turkish language
public | french_noaccent |
public | spanish_noaccent |
最后\ o /
我不确定为什么这个访问权限来自哪里有错误,但我认为它来自AWS RDS:在RDS实例启动时,我曾要求使用guilty数据库创建用户。它可能是别的东西,但我认为这是两个数据库之间唯一的区别。
很抱歉这篇长篇文章,但毕竟它只是我下午的摘要:D