思考sphinx未知类型'mysql';跳绳

时间:2011-07-04 12:05:56

标签: ruby ruby-on-rails-3 thinking-sphinx

我正在使用ts版本2.0.5,rails 3.0.9和mysql2 0.2.11

尝试使用rake ts:index创建索引时,出现以下错误:

ERROR: source 'technical_core_0': unknown type 'mysql'; skipping.

我的development.sphinx.conf包含:

source technical_core_0
{
  type = mysql
  sql_host = localhost
  sql_user = root
  sql_pass = 
  sql_db = ps_development
  sql_sock = /tmp/mysql.sock
  sql_query_pre = SET NAMES utf8
  sql_query_pre = SET TIME_ZONE = '+0:00'
  sql_query = SELECT SQL_NO_CACHE `technicals`.`id` * CAST(1 AS SIGNED) + 0 AS `id` , `orders`.`name` AS `author`, `technicals`.`id` AS `sphinx_internal_id`, 0 AS `sphinx_deleted`, 488243725 AS `class_crc`, IFNULL(`orders`.`name`, '') AS `author_sort`, `technicals`.`order_id` AS `order_id`, UNIX_TIMESTAMP(`technicals`.`created_at`) AS `created_at`, UNIX_TIMESTAMP(`technicals`.`updated_at`) AS `updated_at` FROM `technicals` LEFT OUTER JOIN `orders` ON `orders`.`id` = `technicals`.`order_id` WHERE (`technicals`.`id` >= $start AND `technicals`.`id` <= $end) GROUP BY `technicals`.`id`, , `orders`.`name`, `technicals`.`id`, `orders`.`name`, `technicals`.`order_id`, `technicals`.`created_at`, `technicals`.`updated_at` ORDER BY NULL
  sql_query_range = SELECT IFNULL(MIN(`id`), 1), IFNULL(MAX(`id`), 1) FROM `technicals` 
  sql_attr_uint = sphinx_internal_id
  sql_attr_uint = sphinx_deleted
  sql_attr_uint = class_crc
  sql_attr_uint = order_id
  sql_attr_timestamp = created_at
  sql_attr_timestamp = updated_at
  sql_attr_str2ordinal = author_sort
  sql_query_info = SELECT * FROM `technicals` WHERE `id` = (($id - 0) / 1)
}

我的database.yml文件包含mysql2和root密码,这有点奇怪。

你能帮助我度过这个阶段吗?我还尝试使用:

创建一个sphinx.yml文件
development:
 adapter: mysql2

但这也失败了。

- 更新 -

我将其添加到开发初始化文件中:

 ThinkingSphinx.database_adapter = :mysql2

这给出了只支持MySQL的错误。

4 个答案:

答案 0 :(得分:64)

根据链接here,您可以在homebrew(mac)上执行以下操作:

brew install sphinx --with-mysql

这对我有用:)

答案 1 :(得分:14)

在编译Sphinx时,您应该指定--with-mysql标志。

$ ./configure --with-mysql
$ make
$ sudo make install

您可能需要指定MySQL库的包含文件的位置。例如,在全新安装的OS X上:

$ ./configure --with-mysql=/opt/local/include/mysql5

答案 2 :(得分:3)

当通过自制程序在OSX上安装时,请尝试:

sudo ln -s /usr/local/mysql/lib /usr/local/mysql/lib/mysql
brew install --interactive sphinx
./configure
make
make install
exit

答案 3 :(得分:2)

生成的源看起来是正确的 - 您的Sphinx版本是否可能在没有MySQL支持的情况下编译?