Thanks guys. Unfortunatley, there are infinite combinations that someone might search on, so manual definition won't work for me. I think my options are to define my attributes as indexes (at a performance cost), or alter the requirements to exclude attributes from the "or" logic.
Whatever I do, I'll take Pat's advice about conditions/with. Thanks again, - Josh On Jul 21, 11:38 am, Pat Allan <[email protected]> wrote: > On 21/07/2009, at 8:39 AM, James Healy wrote: > > > > > > >> These search examples could be handled by passing the attribute > >> using :conditions or :with. But what I'm still stuck on is how to > >> accomplish this: > > >> Model.search("(@string foo | @attribute 1)") > > >> As far as I can tell, this isn't possible. Any chance someone has > >> found a solution for this? > > > Pat may correct me, but I'm pretty sure filters don't allow OR > > conditions. > > > My (somewhat limited) workaround is to define a new attribute that has > > the OR defined in SQL: > > > has "IF(active = 1 OR in_stock > 0, 1, 0)", :as > > => :available, :type => :boolean > > James is spot on - can't use OR with different filters (although > passing an array of values into a single filter uses OR logic). Josh, > I think you'll need to follow James' example with the manual > definition of an attribute. > > Also, I highly recommend you put attribute filters in :with, > not :conditions - I'll be deprecating that soon, forcing fields to be > in :conditions, attributes in :with (makes for cleaner code, thus > easier to maintain). > > Cheers > > -- > Pat --~--~---------~--~----~------------~-------~--~----~ 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 -~----------~----~----~----~------~----~------~--~---
