Search code examples
ruby-on-railsthinking-sphinx

How to search for dates before 1970 with thinking sphinx?


I have a search like so in my rails app:

Publication.search(terms, :with => {:publish_date => start_date..end_date})

However, if the start_date is before 1/1/1970, due to UNIX timestamps, the results will not show. I have records that have a publish_date before 1970 so I was just wondering what the best solution for this is, as I haven't been able to find one yet.


Solution

  • You could look at storing them as integers by date, rather than timestamp: e.g. 1st January 1970 becomes 19700101.

    This does mean you'd need to manually wrangle dates into the appropriate format within your index definitions though, and translate search requests accordingly too.