4

how can i integrate Convert_tz of Mysql in thinking sphinx? i tried to look up for answers but i'am not able to find any. I'am using ruby - 1.9.3 and rails 3.2 thinking sphinx 2.0.11

eg: Model.search("", with: {attribute: ">=CONVERT_TZ(#{Time.now}, 'UTC', 'America/New_York')" })

Aditya Kamatar
  • 363
  • 1
  • 7

1 Answers1

0

Sphinx has no concept of timezones, and so it doesn't have the CONVERT_TZ function (or anything like it). By default, Sphinx will store times as whatever they're in your database as (very likely UTC), so your best bet is to convert times to the appropriate UTC values when filtering.

And if you want to use greater-than/less-than logic in filters, it needs to be done as a range:

Model.search with: {attribute: Time.zone.now..1.year.from_now}
pat
  • 16,116
  • 5
  • 40
  • 46