<p>You can combine <code>OR</code>s within the same column but you can't easily combine multiple columns with an <code>OR</code> statement.</p>

<pre><code>craft.entries.yourFieldHandle('OR, x, y, z').anotherFieldHandle('OR, d, e')
</code></pre>

CC BY-SA 3.0
2018-03-13T20:34:08.440Z
2018-03-13T20:34:08.440Z
Robin Schambach
<p>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.</p>
<blockquote>
<p>Robin is correct here: <a href="https://craftcms.stackexchange.com/questions/24195/search-query-grouping-and-merging-multiple-searches">Search query: grouping and merging multiple searches</a></p>
<p>If you're looking for more complex, you might be able to pull it off with a plugin that listened to the onBuildElementsQuery event (<a href="https://craftcms.com/docs/plugins/events-reference#elements-onBuildElementsQuery" rel="nofollow noreferrer">https://craftcms.com/docs/plugins/events-reference#elements-onBuildElementsQuery</a>) or possibly through an external search service like Algolia. There's a Craft integration for the latter here: <a href="https://transition.topshelfcraft.com/software/craft/searchplus/overview" rel="nofollow noreferrer">https://transition.topshelfcraft.com/software/craft/searchplus/overview</a></p>
</blockquote>
<p>Thanks again</p>
<p>Gavin</p>

CC BY-SA 3.0
2018-03-14T10:15:24.397Z
2018-03-14T10:15:24.397Z
2020-06-17T08:56:27.903Z
Gavin Platt
<p>Is it possible to 'group' search logic in the <code>craft.entries.search</code> query? I need to do the following: <code>[a OR b OR c]  AND  [d OR e]  AND  [x OR y OR z]</code></p>

<p>Thanks!</p>

<entries><search>
Search query: grouping and merging multiple searches
# Search query: grouping and merging multiple searches

(Asked by: username_0 on 2018-03-13)

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!

**Tags:** entries, search


---

## 2 answers

### Answer by username_1 on 2018-03-13. Score: 1 | Accepted answer

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')


---

### Answer by username_0 on 2018-03-14. Score: 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](https://craftcms.stackexchange.com/questions/24195/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


---

