我真的需要帮助安装Sphinx并让它继续运行。
我在轨道3上,我正在按照这些方向:http://freelancing-god.github.com/ts/en/quickstart.html来安装Sphinx。
思考Sphinx很容易安装,因为它是一颗宝石。但是,指南说我需要安装Sphinx 和 Thinking Sphinx才能开始使用(这是真的吗?)。我检查了Ryan Bates的Thinking Sphinx的railscast,他只安装了插件并立即开始。
无论如何,我通过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。谢谢!
答案 0 :(得分:1)
您需要将mysql
或mysql2
作为适配器 - 并在Gemfile中包含gem(与适配器相同的名称)。我建议使用mysql2,因为它是主动维护的 - 但请记住,如果你使用的是Rails 3.0.x,那么你必须使用0.2.x版本的mysql2。如果您使用的是Rails 3.1,那么请使用mysql2 0.3.x。