You're looking at advanced query building if you start getting into using both AND and OR together. I would start by questioning do your users actually need this level complexity in their filtering.
If you do have power users in this category and it's necessary for them. Then you probably need to implement both a simple & advanced query builder.
Here's an example from JIRA a ticket management system. Their search is effectively a filter as leaving it blank returns all tickets.
Their advanced search essentially takes in a text-based query string. The beauty of a query string is that it's very easy to group items together using brackets. However, the user now needs to learn syntax.
JIRA's query string field does provide autosuggestions as you type. That reduces the cognitive load a bit. They also provide detail documentations on their custom query language so you can look up specifics: https://confluence.atlassian.com/display/JIRA/Advanced+Searching
This is of course a fair bit of work to set up. Which is why I ask, would your users truly need this ability.
Okay if users really need conditionals, can you get away with a simplified version sort of like an email client mail rule builder which only allows AND or OR but not a mix?
Or how about a faceted search like on an e-commerce site?
You need to come up with sensible "AND" and "OR" options for the user beforehand, but most users have been on an e-commerce site before and knows how to use a faceted search filter.