Sphinx 的 sql_range_query 错误

发布于 2024-11-17 17:32:57 字数 966 浏览 5 评论 0原文

在我的生产服务器上设置 Sphinx 时,尝试索引时出现了这个奇怪的错误

ERROR: index 'benefit_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 '' at line 1

,这在我的本地计算机上不会发生。是的,那是一个空字符串。

以前有人见过这种类型的问题吗?

benefit.rb

define_index do 
  # Fields
  indexes category
  indexes title
  indexes tags
  indexes description
  indexes brief_description
  indexes brand
  indexes short_description
  indexes long_description
  indexes benefit_description
  indexes address.city
  indexes address.state
  indexes address.street_1
  where sanitize_sql(["active = true and expiration > ?", Time.now]) 
  set_property :field_weights => {
    :title => 15,
    :tags => 10,
    :brand => 10,
    :description => 3
  }
end

Thinking-Sphinx - 1.4.4

Sphinx - 0.9.9

谢谢!

While setting up Sphinx on my production server, this strange error came up when trying to index

ERROR: index 'benefit_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 '' at line 1

This doesn't happen on my local machine. And yes, that is an empty string.

Does anyone seen this type of issue before?

benefit.rb

define_index do 
  # Fields
  indexes category
  indexes title
  indexes tags
  indexes description
  indexes brief_description
  indexes brand
  indexes short_description
  indexes long_description
  indexes benefit_description
  indexes address.city
  indexes address.state
  indexes address.street_1
  where sanitize_sql(["active = true and expiration > ?", Time.now]) 
  set_property :field_weights => {
    :title => 15,
    :tags => 10,
    :brand => 10,
    :description => 3
  }
end

Thinking-Sphinx - 1.4.4

Sphinx - 0.9.9

Thank you!

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

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

发布评论

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

评论(2

浅浅淡淡 2024-11-24 17:32:57

确保您运行的是最新版本的 Thinking Sphinx,3.0.4 左右。 sanitize_sql 似乎存在一些问题

https:/ /github.com/freelancing-god/thinking-sphinx/issues/213

还尝试将该行重写为

where sanitize_sql(["active = ? and expiration > ?", true, Time.now]) 

还尝试注释掉所有行并逐渐将它们添加回来以确定错误的确切位置发生。

Be sure you are running the most recent version of Thinking Sphinx, 3.0.4 or so. Looks like there has been some issues with sanitize_sql

https://github.com/freelancing-god/thinking-sphinx/issues/213

Also try re-writing the line to be

where sanitize_sql(["active = ? and expiration > ?", true, Time.now]) 

Also try commenting out all the lines and gradually add them back to determine exactly where the error is occurring.

岁月染过的梦 2024-11-24 17:32:57

问题最终出在 sanitize_sql 方法上。我将该行替换为:

where "active = true AND expiration > \"#{Time.now.to_formatted_s(:db)}\""

感谢您的帮助!

The problem ended up being with the sanitize_sql method. I replaced that line with:

where "active = true AND expiration > \"#{Time.now.to_formatted_s(:db)}\""

Thanks for the help!

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