2010-12-20 100 views
0

我爲一個postgres項目安裝了幾個月的sphinx,現在我有一個使用mysql的項目。我試着用這條線在我environments.rb來解決這個問題:我是否需要爲mysql重新安裝思維獅身人面像,如果它以前安裝了postgres?

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. 

對此有何幫助?

+0

您正在運行哪個版本的獅身人面像?你有沒有檢查過searchd配置? – ajreal 2010-12-20 10:08:05

+0

我正在運行Sphinx 0.9.9-rc2(r1785)版權所有(c)2001-2009,安德魯Aksyonoff我也檢查我的配置,它顯示postrges。我改變了這一切,但無濟於事 – corroded 2010-12-20 10:35:53

回答

4

看起來你已經編譯Sphinx來支持PostgreSQL,而不是MySQL。所以你需要重新編譯並重新安裝Sphinx。你不需要在Thinking Sphinx中改變任何東西,這只是修改你的database.yml(我猜你已經完成了),你應該沒問題。

請記住,默認情況下,Sphinx僅編譯MySQL支持。我通常編譯爲MySQL和PostgreSQL和我的配置要求,從獅身人面像源目錄中看起來類似:

./configure --with-pgsql 

希望這是所有的需要 - 除非你有MySQL的一個非標準的位置設置,那麼您可能需要檢查其他標誌 - 運行./configure --help以查看各種選項。

+0

如此噁心卸載我的思維獅身人面像,然後重新編譯爲MySQL和postrges?那可能嗎? – corroded 2010-12-20 11:49:14

+1

您不需要卸載,只需重新編譯用於MySQL和PostgreSQL的Sphinx(而不是思維獅身人面像)即可。它希望應該是相當無痛的。 – pat 2010-12-21 00:07:48

+0

老兄感謝您的幫助!必須重新安裝mysql,因爲我使用的是錯誤的架構,但是你讓我走上了正確的軌道。感謝人 – corroded 2010-12-21 11:16:07

相關問題