在 PostgreSQL 上创建非重音扩展时出错

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/12100638/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 00:13:35  来源:igfitidea点击:

Error when creating unaccent extension on PostgreSQL

postgresqlfull-text-searchpostgresql-9.1rails-postgresqlunaccent

提问by fagiani

I am trying to configure PostgreSQL to use fulltext search in my rails app as mentioned in this Railscast.

我正在尝试将 PostgreSQL 配置为在我的 Rails 应用程序中使用全文搜索,如本Railscast 中所述

I am using a fresh Ubuntu 12.04server running PostgreSQL 9.1.5installed using apt-getwith the ppa:pitti/postgresqlwith precise.

我正在使用与with 一起安装的新Ubuntu 12.04服务器运行。PostgreSQL 9.1.5apt-getppa:pitti/postgresqlprecise

I get the following error when trying to run the migration and when I try the same command in the psql console with the peer postgres user:

尝试运行迁移以及在 psql 控制台中与对等 postgres 用户尝试相同的命令时,出现以下错误:

postgres=# CREATE EXTENSION unaccent;

ERROR: could not open extension control file "/usr/share/postgresql/9.1/extension/unaccent.control":
No such file or directory

错误:无法打开扩展控制文件“/usr/share/postgresql/9.1/extension/unaccent.control”:
没有那个文件或目录

In my local box running Ubuntu 10.04 desktopI use the same repository (natty) and it works well.

在我运行的本地机器中,Ubuntu 10.04 desktop我使用相同的存储库 ( natty) 并且它运行良好。

Any insights would be greatly appreciated.

任何见解将不胜感激。

回答by Erwin Brandstetter

You need to install the package postgresql-contrib-9.1in your system first. (Adapt to your version number! Here is the currently available list of packages.) That's the case under Debian, Ubuntu& friends anyway. Using a system user with the necessary privileges:

您需要先postgresql-contrib-9.1在系统中安装该软件包。(适应您的版本号!这是当前可用的软件包列表。)无论如何,DebianUbuntu和朋友都是这种情况。使用具有必要权限的系统用户:

apt-get install postgresql-contrib-9.1

If your currently logged in user does not have the necessary privileges (but sudorights):

如果您当前登录的用户没有必要的权限(但有sudo权限):

sudo apt-get install postgresql-contrib-9.1

Quoting the PostgreSQL Apt Repository:

引用PostgreSQL Apt 存储库

If the version included in your version of Debian is not the one you want, you can use the PostgreSQL Apt Repository.

如果您的 Debian 版本中包含的版本不是您想要的版本,您可以使用 PostgreSQL Apt Repository。

There are basic install instructions on the Postgres websitefor each available OS.

Postgres的网站上基本安装说明每个可用的操作系统。

For accent-insensitive indices using unaccentconsider this related question:

对于使用不区分重音的索引,请unaccent考虑以下相关问题:

回答by Mingyu

On CentOS:

在 CentOS 上:

sudo yum install postgres*contrib