Haseeb Ahmad
Haseeb Ahmad

Reputation: 8730

How to search data on created at less than in thinking sphinx

Using thinking_sphinx to fetch data from records. It working fine but facing an issue that not find any to get records on date comparison like created_at greater than or less than. I check their official documentation also Thinking Sphinx

Is thinking sphinx provide that way? If yes then can we do that

Upvotes: 0

Views: 100

Answers (1)

pat
pat

Reputation: 16226

It is possible, but it's not entirely obvious.

What you'll need to do is add an extra column in the SELECT clause, and then filter by that. Something along the lines of:

Model.search "pancakes",
  :select => "*, IF(created_at > #{1.year.ago.to_i}, 1, 0) AS time_match",
  :with   => {:time_match => 1}

You will need to have created_at as an attribute in your index file for this to work.

Upvotes: 1

Related Questions