简体   繁体   English

太阳黑子Solr + Rails +时区

[英]Sunspot solr + Rails + timezone

In our rails application we are getting time zone from users. 在我们的Rails应用程序中,我们正在从用户那里获取时区。

select * from questions where created_at + interval '6 hour' between '2014-03-21' and '2014-03-22' 从问题中选择*,其中created_at +介于“ 2014-03-21”和“ 2014-03-22”之间的间隔“ 6小时”

while selection questions from table adding timezone offset to get questions created in some interval. 同时从表中选择问题并添加时区偏移量,以获取在一定间隔内创建的问题。

is it possible to do the same using sunspot solr? 有可能使用黑子solr做同样的事情吗?

For example, 例如,

Question.search do with(:created_at, "2014-03-24T00:00:00Z".."2014-03-24T23:59:59Z") this should added with the offset end Question.search与(:created_at,“ 2014-03-24T00:00:00Z” ..“ 2014-03-24T23:59:59Z”)一起添加偏移量结束

Please help us to achieve this or tell me is it possible with sunspot solr or not. 请帮助我们实现这一目标,或者告诉我是否有可能使用黑子solr。

Thanks, Nandhini 谢谢,Nandhini

This is the basic syntax, not 100% sure about date formats 这是基本语法,并非100%确定日期格式

Question.search do
    with(:created_at).greater_than("2014-03-24T00:00:00Z".to_datetime)
    with(:created_at).less_than("2014-03-24T23:59:59Z".to_datetime)
    ...

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM