0
votes

Why does this return results:

@results = Index.search "#{@keywords}", :with => {
 :published_on => 1.week.ago..Time.now,  
}

but not this?

@results = Index.search "#{@keywords}", :with => {
  :published_on => '2011-04-01'..'2011-04-08',
}

published_on is a datetime field, but I have tried it with hour, minutes and seconds as well.

1

1 Answers

0
votes

Given you're getting results, I'm guessing published_on is actually an attribute, not a field?

If the attribute is a datetime data type, then you need to pass in Ruby Time objects for filters - that, or integer timestamps (which is what Thinking Sphinx converts times to anyway). TS doesn't try to parse strings, so you'll need to manage that yourself.

Sphinx isn't as fancy as MySQL when it comes to auto-parsing dates and times - you need to use the right data type.