Repository/DynamicRepository.php
protected function addSearchFilter($queryBuilder, $search, $searchFields)
    {
        if (empty($search) || empty($searchFields)) {
            return;
        }

        $terms = explode(' ', $search);

        // Search each term in each search field
        foreach ($terms as $counter => $term) {
            $expressions = [];

            foreach ($searchFields as $searchField) {
                $expressions[] = $queryBuilder->expr()->like(
                    'dynamic.' . $searchField,
                    ':searchTerm' . $counter
                );
            }

            $queryBuilder->andWhere(call_user_func_array([$queryBuilder->expr(), 'orX'], $expressions));
            $queryBuilder->setParameter('searchTerm' . $counter, '%' . $term . '%');
        }
    }
protected function addSearchFilter($queryBuilder, $search, $searchFields)
    {
        if (empty($search) || empty($searchFields)) {
            return;
        }

        $terms = explode(' ', $search);

        // Search each term in each search field
        foreach ($terms as $counter => $term) {
            $expressions = [];

            foreach ($searchFields as $searchField) {
                $expressions[] = $queryBuilder->expr()->like(
                    'dynamic.' . $searchField,
                    ':searchTerm' . $counter
                );
            }

            $queryBuilder->andWhere(call_user_func_array([$queryBuilder->expr(), 'orX'], $expressions));
            $queryBuilder->setParameter('searchTerm' . $counter, '%' . $term . '%');
        }
    }
Depending on the given search term, this function filters the result based on search fields.

@param QueryBuilder $queryBuilder
@param string $search
@param string[] $searchFields