searchlogic icon indicating copy to clipboard operation
searchlogic copied to clipboard

How can I use OR with a GROUP of ANDS?

Open timfong888 opened this issue 13 years ago • 1 comments

I want to do the equivalent of (A<x AND B>y) OR (C<x AND D>y). how can i do that?

Right now, I am creating separate queries:

@companies_with_email = Company.contact_emails_date_sent_gt(@monday).
                               contact_emails_date_sent_lt(@friday).
                               find(:all, :select => "distinct companies.*")  || [] 

@companies_with_calls = Company.contact_calls_date_sent_gt(@monday).
                               contact_calls_date_sent_lt(@friday).
                               find(:all, :select => "distinct companies.*")  || []  

And then I @companies_with_calls + @companeis_with_emails

But this will continue to create problems since I don't want duplicates.

I'd like to be able to do it within searchlogic, is this possible?

timfong888 avatar Oct 05 '10 04:10 timfong888

I'm using searchlogic in an old rails 2.3 app (using ransack with all 3.x apps; really need to upgrade this one) and just ran into a case that could use this functionality.

graywh avatar Jul 06 '12 16:07 graywh