1

Is it possible to 'group' search logic in the craft.entries.search query? I need to do the following: [a OR b OR c] AND [d OR e] AND [x OR y OR z]

Thanks!

| improve this question | | | | |
1

You can combine ORs within the same column but you can't easily combine multiple columns with an OR statement.

craft.entries.yourFieldHandle('OR, x, y, z').anotherFieldHandle('OR, d, e')
| improve this answer | | | | |
1

Thanks Robin, that answers my question. I also emailed Craft support – posting Brad's response below for posterity, which suggests other ways to approach this.

Robin is correct here: Search query: grouping and merging multiple searches

If you're looking for more complex, you might be able to pull it off with a plugin that listened to the onBuildElementsQuery event (https://craftcms.com/docs/plugins/events-reference#elements-onBuildElementsQuery) or possibly through an external search service like Algolia. There's a Craft integration for the latter here: https://transition.topshelfcraft.com/software/craft/searchplus/overview

Thanks again

Gavin

| improve this answer | | | | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.