不幸的思考Sphinx不能简单地将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`
任何人都知道如何解决这个问题? 提前谢谢。
答案 0 :(得分:2)
我猜这是TS的一个不好的例子 - 尝试UNSIGNED INT
而不是INT
。
答案 1 :(得分:1)
只是一个额外的想法。检查您的数据库是否具有它正在尝试索引的列是值得的。如果列不存在,它会抛出相同的错误,这会使错误消息略微无法形成。
运行rake db:migrate修复了所有这一切,因为我刚刚将prod副本加载到开发中进行测试,并且没有思考的sphinx delta列在此数据库副本中。
希望这有助于其他发现类似问题的人。