Thanks for the suggestion Kirill - however, that'll only work for fields, and it seems Josh is after a solution with attributes (even though the example given is a field - attributes are a better fit).
Josh, if you're not already, I'd recommend using Sphinx 1.10-beta or better, and then you could use something like this approach: http://freelancing-god.github.com/ts/en/common_issues.html#or_attributes Event.search 'foo', :sphinx_select => "*, IF(published_at < NOW() OR user_id = #{current_user.id}, 1, 0) AS included", :with => {'included' => 1} Make sure you have both columns added as attributes in your define_index block: has published_at, user_id Cheers -- Pat On 08/06/2011, at 6:53 AM, Kirill Radzikhovskyy wrote: > Hi, > > quick response > you can use :boolean match mode > > http://freelancing-god.github.com/ts/en/searching.html#matchmodes > > > Kirill R > > > On 8 June 2011 14:35, Josh <[email protected]> wrote: > After much digging, I don't think this possible - but it can't hurt to > ask: > > I have Events, and they belong to Users. Events can be published or > not published. > > I want to: > > a) If no user is logged in return only published events > b) If a user is logged in return published events OR user_id == > current_user.id > > So, I'd be passing current_user.id into search() > > So for published, I've got this index: > > indexes "published_at < now()", :as => :published > > so, :conditions => {:published => 1} for the published events > > How do I add the OR condition to this? > > > > > > > > > > > > > -- > 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. > > > > > -- > "To recurse is human, to box a continuation into an object and send it across > a network is divine. " > -- Andy Kitchen > > "Debugging is twice as hard as writing the code in the first place. > Therefore, if you write the code as cleverly as possible, you are, by > definition, not smart enough to debug it." > -- Brian W. Kernighan. > > > -- > 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.
