ThinkingSphinx,设置“时间”属性的问题

发布于 2024-11-27 21:06:00 字数 1014 浏览 0 评论 0原文

不幸的是,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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

走过海棠暮 2024-12-04 21:06:00

我猜这是 TS 中的一个坏例子 - 尝试使用 UNSIGNED INT 而不是 INT

I guess that's a bad example from TS - try UNSIGNED INT instead of INT.

一场春暖 2024-12-04 21:06:00

只是一个额外的想法。检查您的数据库是否也包含它尝试索引的列是值得的。如果该列不存在,它可能会抛出相同的错误,这使得错误消息稍微缺乏信息。

运行 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.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文