Closed suzi2000 closed 13 years ago
You'd definitely need to do a custom where or a search_method to achieve this. The "or" behavior splits the condition off into two separate contains_all conditions against each of the OR'ed fields, and then combines them with an OR, as you observed.
I am having a Product with :title and :description. To allow users to search in both through one search field, i am using the ORed _or to join the fields.
Also, i am splitting the params of this field into an array to allow users to enter mutliple search terms in a single form. This is why i also append the _all to make sure the results match all terms entered by the user.
If the user enters 2 search terms, title_or_description_contains_all will match only results that have both terms in title or both terms in description. It does not deliver results where one term is in title and the other in description.
So the logic i would have expected was
(title_or_description)_contains_all
but instead it seems to do
(title_contains_all) or (description_contains_all)
This may be how arel works so maybe not really an issue of Meta_search. But is there a way how to express this with the existing wheres or would i need to write a custom Where or scope?
Thanks :)