Searching by Date Range

256 views
Skip to first unread message

Ryan Bates

unread,
Jul 24, 2008, 4:29:04 PM7/24/08
to Thinking Sphinx
When passing :conditions it doesn't work to pass a range with time
values:

Article.search :conditions => { :created_at => 2.weeks.ago..Time.now }

This raises an exception saying can't convert time to integer. However
if I convert it to an integer on my end:

Article.search :conditions => { :created_at =>
2.weeks.ago.to_i..Time.now.to_i }

That works, but is a bit ugly. I imagine Thinking Sphinx would be able
to do this behind the scenes?

Also, while I'm at it, is there any way to specify greater_than/
less_than conditions besides using a range with extremely low/high
values on one end?

Thanks.

Regards,

Ryan

Pat Allan

unread,
Jul 24, 2008, 5:03:09 PM7/24/08
to thinkin...@googlegroups.com
Hi Ryan

Re date ranges: You're right, it is a bit ugly, and it would be nice
if it changed. Consider it on the list of things to do.

And unfortunately there's no way (beyond using Very Large Values) to
get a greater-than/less-than filter happening. Sphinx only cares about
arrays and ranges (and a single value is just a one-item array).

Cheers

--
Pat

Ryan Bigg

unread,
Aug 14, 2008, 3:00:51 AM8/14/08
to Thinking Sphinx
I'm trying to search on a field called "future_contact_date" using
date ranges... converting it to time and then to i doesn't work. Is
there anything I can do?

Ryan Bigg

unread,
Aug 14, 2008, 3:09:25 AM8/14/08
to thinkin...@googlegroups.com
Ignore me, I didn't have the field indexed!
Reply all
Reply to author
Forward
0 new messages