views:

292

answers:

2

What would be the best approach to have Thinking Sphinx only index records where Today's date is less than or equal to the record's "expires_at" field?

Thanks in advance.

+3  A: 

Hi Adam

The easiest approach is adding the following statement to your define_index block:

where "expired_at >= NOW()"

That's the MySQL version, anyway. PostgreSQL will be pretty similar:

where "expired_at >= current_timestamp"

Although, I'm no PostgreSQL expert, but hopefully that's close enough to what's needed.

Cheers

pat
A: 

PostgreSQL also accepts the function 'now()'

Nikhil Gupte