【发布时间】:2011-09-10 03:27:47
【问题描述】:
我真的需要帮助安装 Sphinx 并让它运行起来。
我在 Rails 3 上,我正在遵循这些方向:http://freelancing-god.github.com/ts/en/quickstart.html 安装 Sphinx。
Thinking Sphinx 很容易安装,因为它是一个 gem。但是,指南说我需要同时安装 Sphinx 和 Thinking Sphinx 才能开始使用(这是真的吗?)。我查看了 Ryan Bates 的 Railscast 中的 Thinking Sphinx,他只安装了插件并立即开始使用。
无论如何,我通过 MacPorts 安装了 Sphinx,这是证明:
...
---> Configuring mysql5
---> Building mysql5
---> Staging mysql5 into destroot
---> Installing mysql5 @5.1.57_0
The MySQL client has been installed.
...
---> Installing sphinx @0.9.9_0+mysql5
---> Activating sphinx @0.9.9_0+mysql5
---> Cleaning sphinx
它自动使用 mysql5 配置 Sphinx。我有 mySQL 和 POSTgreSQL。
在我的用户模型中设置索引后,下一步是rake thinking_sphinx:index,如下所示:
define_index do
indexes year
indexes major
indexes books_buy
indexes books_sell
indexes facebook
indexes restaurants
indexes interests
end
但是,rake thinking_sphinx:index 给了我这个:
rake aborted!
Don't know how to build task 'thinking_sphnix:index'
然后
rake aborted!
no such file to load -- sqlite3
所以我认为我的数据库仍然是在 sqlite3 上配置的。所以我将 gem 切换到 mySQL 并编辑了我的 database.yml 文件,如下所示:
# Switched over to mysql
# Warning: The database defined as "test" will be erased and
# re-generated from your development database when you run "rake".
# Do not set this db to the same as development or production.
development:
adapter: mysql5
encoding: utf8
database: sphinx_development
pool: 5
username: root
password:
socket: /tmp/mysql.sock
test:
adapter: mysql5
encoding: utf8
database: sphinx_test
pool: 5
username: root
password:
socket: /tmp/mysql.sock
production:
adapter: mysql5
encoding: utf8
database: sphinx_production
pool: 5
username: root
password:
socket: /tmp/mysql.sock
我得到了这些错误:
rake aborted!
Please install the mysql5 adapter: `gem install activerecord-mysql5-adapter` (no such file to load -- active_record/connection_adapters/mysql5_adapter)
和
ERROR: Could not find a valid gem 'activerecord-mysql5-adapter' (>= 0) in any repository
ERROR: Possible alternatives: activerecord-jdbcmysql-adapter, activerecord-nulldb-adapter, activerecord-odbc-adapter, activerecord-jdbc-adapter, activerecord-postgis-adapter
Tony-Ngs-MacBook-Air:sample_app TonyNg$ gem install activerecord-nulldb-adapter
任何提示都会很慷慨和有帮助。如果提供帮助,也愿意切换到 PostgreSQL。谢谢!
【问题讨论】:
-
所以您决定忽略告诉您具体该怎么做的错误消息? "请安装mysql5适配器:
gem install activerecord-mysql5-adapter" -
不,我也试过了,得到:
ERROR: Could not find a valid gem 'activerecord-mysql5-adapter' (>= 0) in any repository ERROR: Possible alternatives: activerecord-jdbcmysql-adapter, activerecord-nulldb-adapter, activerecord-odbc-adapter, activerecord-jdbc-adapter, activerecord-postgis-adapter -
首先,sphinx只支持mysql和postgresql,不支持sqlite3。另外,要验证您是否安装了 Sphinx,您的路径中是否有“searchd”?那是狮身人面像搜索守护进程。听起来你需要创建你的开发 MySQL 数据库,你需要通过 mysql 提示符来完成。
-
@Cody Caughlan。是的,我在 opt/local/bin 下确实有“searchd”。我刚刚创建了一个开发 MySQL 数据库。是的,我明白 sphinx 只支持这两个选项。
标签: mysql sphinx thinking-sphinx