Combining AND and OR with Field Search filter
Hi Low,
I would like to have same feature with AND/OR condition but sorry I couldn't understand exactly what to do with this discussion.
Let me explain. My low:search form code is like:
My seach form is like:
{exp:low_search:form}
Field 1:
#####
Field 2:
#####
Field 3:
#####
AND
OR
{/exp:low_search:form}
On changing and_or select box to OR, I am updating require_all value as "search:field1|search:field2|search:field3" i.e
But it doesn't seem working for OR. Could you please guide me where I am going wrong.
Thanks,
Note: This topic was created from a reply on the Possible to specify AND/OR custom field searches? topic.
Replies
Low 15 Jan 2014 08:12
Moving your reply to a new thread removed some of the formatting. Here is the code you originally had:
Low 15 Jan 2014 08:21
So, my question to you is, what are you expecting? A setup like yours will always result in something like:
(field1-a OR field1-b) AND (field2-c OR field2-d) AND (field3-e OR field3-f)
where -a and -b are values for each field.
Adding the parameter names to the require_all value, will change that to
(field1-a AND field1-b) AND (field2-c AND field2-d) AND (field3-e AND field3-f)
The different parameters (fields) are always separated with AND, just like you would expect in actual parameter syntax:
You could simplify your template by removing the hidden field and use this instead:
Bhashkar Yadav 15 Jan 2014 18:17
Hi Low,
Thanks for your kind response. Simply, I would like to have "Field1 OR Field2 OR Field3" for OR filter. Same like AND filter: "Field1 AND Field2 AND Field3".
Could you please guide me.
Thanks
Low 15 Jan 2014 20:42
Using OR between different parameters is not possible. That's what the Feature Request thread is about.
Bhashkar Yadav 15 Jan 2014 20:48
Thanks Low.
I was looking for extension hooks of Low Search but couldn't find any suitable hook for it.
Could you please guide if its possible via any extension hook from http://gotolow.com/addons/low-search/...
Thanks
Low 15 Jan 2014 20:51
For a custom solution, your best bet is to use the low_search_pre_search hook, read out your parameters, perform your queries and set the entry_id parameter with the search results accordingly.