ThinkingSphinx,设置“时间”属性的问题
不幸的是,Thinking 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 => ; :整数, :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`
有人知道如何解决这个问题吗? 提前致谢。
Unfortunatelly Thinking Sphinx can't simply convert time
field to attribute
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)
Changing to has "CAST(column AS INT)", :type => :integer, :as => :column
syntax also don't fix that:
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`
Anyone knows how to fix that?
Thanks in advance.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
我猜这是 TS 中的一个坏例子 - 尝试使用
UNSIGNED INT
而不是INT
。I guess that's a bad example from TS - try
UNSIGNED INT
instead ofINT
.只是一个额外的想法。检查您的数据库是否也包含它尝试索引的列是值得的。如果该列不存在,它可能会抛出相同的错误,这使得错误消息稍微缺乏信息。
运行 rake db:migrate 修复了所有这些问题,因为我刚刚将一个产品副本加载到开发中进行测试,并且该数据库副本中没有任何思考 sphinx delta 列。
希望这对发现类似问题的其他人有所帮助。
Just an extra thought. It pays to check your database has the column it is trying to index as well. It can throw the same error if the column doesn't exist which makes the error message slightly un imformative.
Running rake db:migrate fixed all of this as I just loaded a prod copy into development for testing and none of the thinking sphinx delta columns were in this database copy.
Hope this helps anyone else who finds a similar problem.