2011-08-05 114 views
0

可惜的是獅身人面像的思考不能簡單地轉換time字段屬性ThinkingSphinx,與設置`time`屬性問題

class Place << ActiveRecord::Base 
#... relations 

define_index 
    #... 
    has breakfast_start, :as => breakfast_start 
end 

rake ts:rebuild

rake aborted! 

Cannot automatically map attribute breakfast_start in Place to an 
equivalent Sphinx type (integer, float, boolean, datetime, string as ordinal). 
You could try to explicitly convert the column's value in your define_index 
block: 
    has "CAST(column AS INT)", :type => :integer, :as => :column 

(See full trace by running task with --trace) 

更改爲has "CAST(column AS INT)", :type => :integer, :as => :column語法也沒有解決這個問題:

ERROR: index 'place_core': sql_range_query: You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'INT) AS `breakfast_start` FROM `places` 

任何人都知道如何解決這個問題? 在此先感謝。

回答

2

我想這是來自TS的一個壞例子 - 試試UNSIGNED INT而不是INT

+0

哇。非常快速的答覆。它的工作原理!你搖滾! :d –

1

只是一個額外的想法。檢查數據庫是否有試圖索引的列是值得的。如果列不存在,那麼它會拋出相同的錯誤,這會使錯誤消息稍微變形。

運行rake db:migrate修復了所有這些,因爲我只是將一個prod副本加載到開發中進行測試,並且沒有思想sphinx delta列在此數據庫副本中。

希望這可以幫助任何發現類似問題的人。