Hi Will

An alternative is you could create an attribute to filter by:

  has "expires_on IS NULL OR expires_on > NOW()", :as => :active, :type => 
:boolean

Or put that logic with your WHERE clause, much like you've already done. Mind 
you, your solution is much cleaner from a index-definition point of view :)

-- 
Pat

On 09/12/2009, at 5:49 AM, Will Clark wrote:

> If anyone is dealing with the same situation, I ended up creating a
> rake task that would find all the expired listings once a day, and
> update the active column to false, and I can easily use that column in
> my searches.
> 
> define_index do
>    indexes title, description, city
>    where "active = 't'"
> end
> 
> 
> On Dec 8, 11:10 am, Will Clark <[email protected]> wrote:
>> I have a directory of listings each with an expires_on column. I'd
>> like the search results to return anything that has an expires_on >
>> Date.today OR expires_on IS NULL (for listings that have no expiration
>> date).
>> 
>> Is it best to add that in the define_index block (if so, with a where
>> statement?), or as a :condition of the search itself?
> 
> --
> 
> You received this message because you are subscribed to the Google Groups 
> "Thinking Sphinx" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to 
> [email protected].
> For more options, visit this group at 
> http://groups.google.com/group/thinking-sphinx?hl=en.
> 
> 

--

You received this message because you are subscribed to the Google Groups 
"Thinking Sphinx" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/thinking-sphinx?hl=en.


Reply via email to