Magento 2.x – How to manage multiple AND and OR conditions to filter / filterGroups

If you are trying to get and filter data for certain collection, using its repository. You will need to to create a Searchcritearia as follows:

  • Inject the following dependencies:
  • Perform the needed filters like this:


As a full example, in the below code, we are filtering the cms blocks repository: