【问题标题】:do i need to reinstall thinking sphinx for mysql if it was previously installed for postgres?如果以前为 postgres 安装了 Thinking sphinx,我是否需要为 mysql 重新安装 Thinking sphinx?
【发布时间】:2010-12-20 09:43:45
【问题描述】:

几个月前我为一个 postgres 项目安装了 sphinx,现在我有一个使用 mysql 的项目。我试图在我的environments.rb中用这一行来解决这个问题:

ThinkingSphinx.database_adapter = :mysql

我什至为这个项目生成了一个 development.sphinx.conf:

source article_core_0
{
  type = mysql
  sql_host = localhost
  sql_user = ***
  sql_pass = ***
  sql_db = ***_development
  sql_sock = /tmp/mysql.sock
  sql_query_pre = UPDATE `articles` SET `delta` = 0 WHERE `delta` = 1
  sql_query_pre = SET NAMES utf8
  sql_query_pre = SET TIME_ZONE = '+0:00'
  sql_query = SELECT SQL_NO_CACHE `articles`.`id` * 6 + 0 AS `id` , `articles`.`title` AS `title`, `articles`.`content` AS `content`, GROUP_CONCAT(DISTINCT IFNULL(`tags`.`tag`, '0') SEPARATOR ' ') AS `tag`, GROUP_CONCAT(DISTINCT IFNULL(`customer_categories`.`name`, '0') SEPARATOR ' ') AS `category`, CONCAT_WS(' ', `users`.`first_name`, `users`.`last_name`) AS `created_by_user_name`, `articles`.`id` AS `sphinx_internal_id`, 3448190970 AS `class_crc`, 0 AS `sphinx_deleted`, `articles`.`account_id` AS `account_id`, `articles`.`internal_only` AS `internal_only`, UNIX_TIMESTAMP(`articles`.`created_at`) AS `created_at`, UNIX_TIMESTAMP(`articles`.`updated_at`) AS `updated_at`, `articles`.`views` AS `views` FROM `articles` LEFT OUTER JOIN `articles_tags` ON `articles_tags`.`article_id` = `articles`.`id` LEFT OUTER JOIN `tags` ON `tags`.`id` = `articles_tags`.`tag_id` LEFT OUTER JOIN `articles_categories` ON `articles_categories`.`article_id` = `articles`.`id` LEFT OUTER JOIN `customer_categories` ON `customer_categories`.`id` = `articles_categories`.`customer_category_id` LEFT OUTER JOIN `users` ON `users`.`id` = `articles`.`created_by_id` WHERE (`articles`.`id` >= $start AND `articles`.`id` <= $end AND `articles`.`delta` = 0) GROUP BY `articles`.`id`, `articles`.`title`, `articles`.`content`, `users`.`first_name`, `users`.`last_name`, `articles`.`id`, `articles`.`account_id`, `articles`.`internal_only`, `articles`.`created_at`, `articles`.`updated_at`, `articles`.`views` ORDER BY NULL
  sql_query_range = SELECT IFNULL(MIN(`id`), 1), IFNULL(MAX(`id`), 1) FROM `articles` WHERE `articles`.`delta` = 0
  sql_attr_uint = sphinx_internal_id
  sql_attr_uint = class_crc
  sql_attr_uint = sphinx_deleted
  sql_attr_uint = account_id
  sql_attr_uint = views
  sql_attr_bool = internal_only
  sql_attr_timestamp = created_at
  sql_attr_timestamp = updated_at
  sql_query_info = SELECT * FROM `articles` WHERE `id` = (($id - 0) / 6)
}

问题是我不断收到此错误:

Sphinx 0.9.9-rc2 (r1785)
Copyright (c) 2001-2009, Andrew Aksyonoff

using config file '/Users/eumir/rails_apps/hivemind/config/development.sphinx.conf'...
indexing index 'article_core'...
ERROR: source 'article_core_0': unknown type 'mysql'; skipping.
ERROR: index 'article_core': failed to configure some of the sources, will not index.
indexing index 'article_delta'...
ERROR: source 'article_delta_0': unknown type 'mysql'; skipping.
ERROR: index 'article_delta': failed to configure some of the sources, will not index.
distributed index 'article' can not be directly indexed; skipping.
indexing index 'contact_core'...
ERROR: source 'contact_core_0': unknown type 'mysql'; skipping.

有什么帮助吗?

【问题讨论】:

  • 你运行的是哪个版本的狮身人面像?你检查过搜索配置吗?
  • 我正在运行 Sphinx 0.9.9-rc2 (r1785) 版权所有 (c) 2001-2009,Andrew Aksyonoff 我还检查了我的配置,它显示了 postrges。我将其更改为 mysql 但无济于事

标签: mysql ruby-on-rails postgresql thinking-sphinx


【解决方案1】:

看起来您已将 Sphinx 编译为仅支持 PostgreSQL,而不是 MySQL。因此,您需要重新编译并重新安装 Sphinx。您不需要更改 Thinking Sphinx 中的任何内容,只需修改您的 database.yml(我猜您已经完成了),您应该没问题。

请记住,默认情况下,Sphinx 仅针对 MySQL 支持进行编译。我通常为 MySQL 和 PostgreSQL 编译它,我在 Sphinx 源目录中的配置请求如下所示:

./configure --with-pgsql

希望这就是所有需要的 - 除非您在非标准位置设置 MySQL,否则您可能需要检查其他标志 - 运行 ./configure --help 以查看各种选项。

【讨论】:

  • 所以不想卸载我的思考狮身人面像然后重新编译mysql和postrges?这可能吗?
  • 您无需卸载,只需为 MySQL 和 PostgreSQL 重新编译 Sphinx(不是 Thinking Sphinx)。希望它应该很无痛。
  • 老兄感谢您的帮助!不得不重新安装 mysql,因为我使用了错误的架构,但你让我走上了正确的轨道。谢谢人
  • 这与我的问题类似:Homebrew 似乎默认不安装 postgres 支持。我用--pgsql 重新安装了它,它工作了。
猜你喜欢
  • 2012-08-02
  • 1970-01-01
  • 1970-01-01
  • 2012-01-07
  • 2013-01-31
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
  • 1970-01-01
相关资源
最近更新 更多