Set the search criteria.

@param string $q

@return self
421389
public function search($q)
    {
        /* @var \Doctrine\ODM\MongoDB\Query\Builder $qb */
        $qb = $this->repository->createQueryBuilder();
        $qb->field('title')->equals(new \MongoRegex('/' . addslashes($q) . '/i'));
        $cursor = $qb->getQuery()->execute();

        $adapter = new DoctrineMongoCursor($cursor);
        parent::__construct($adapter);

        return $this;
    }
943151
public function search(ODataQuerySearch $search = NULL) {
        if (isset($search)) {
            $this->setSearch($search);
            return $this;
        }
        return $this->getSearch();
    }
1366413
protected function addCriteriaToPositionQuery($query)
    {
        // Find products in the same category
        $products = ProductCategoryQuery::create()
            ->filterByCategoryId($this->getDefaultCategoryId())
            ->filterByDefaultCategory(true)
            ->select('product_id')
            ->find();

        if ($products != null) {
            $query->filterById($products, Criteria::IN);
        }
    }
189081
protected function setSearchCriteriaFromPost()
    {
        $this->initSearchCriteria();

        foreach ($this->aCriteria as $sIndex => $mValue) {
            $this->aCriteria[$sIndex] = $this->app['request']->request->get($sIndex, $mValue);
        }
    }
431730
public function setQuery(?string $query = null): self
    {
        $this->query = $query;
        $this->query = $this->query ?? '';

        return $this;
    }
1017534
public function addFilterToQueryBuilder(QueryBuilder $qb)
    {
        $filters = $this->dm->getFilterCollection()->getFilterCriteria($this->class);

        foreach ($filters as $filter) {
            $qb->addCriteria($filter);
        }
    }
268825
public function query($qs = null)
    {
        if (func_num_args() === 0) {
            return $this->_query;
        }
        if (is_string($qs)) {
            parse_str($qs, $qs);
        }
        $this->_query = $qs + $this->_query;
        return $this;
    }
150206
private function applyCriteriaToQueryBuilder(array $criteria, QueryBuilder $qb)
    {
        foreach ($criteria as $key => $value) {
            if (in_array($key, ['treeId', 'teaserId', 'eid', 'version'])) {
                $qb->andWhere($qb->expr()->eq("h.$key", $value));
            } elseif (in_array($key, ['language', 'action'])) {
                $qb->andWhere($qb->expr()->eq("h.$key", $qb->expr()->literal($value)));
            } elseif (in_array($key, ['comment'])) {
                $qb->andWhere($qb->expr()->like("h.$key", $qb->expr()->literal("%$value%")));
            } else {
                throw new InvalidArgumentException("Unkown field $key");
            }
        }
    }
520958
public function filterEq(string $field, $value): self
    {
        $this->filters[] = new IndexQueryFilter($field, IndexQueryFilterOperator::EQUAL_TO(), $value);
        return $this;
    }
1260595
public function setQueryString(array $query): self
    {

        foreach ($query as $key => $value) {
            if (is_array($value)) {
                $query[$key] = implode(',', $value);
            }
        }

        $this->query_string = array_merge($this->query_string, $query);

        return $this;
    }
838332
protected function applyPagination(RestRequestContract $request, QueryBuilder $qb)
    {
        $qb->addCriteria(
            new Criteria(null,
                $request->getOrderBy(),
                $request->getStart(),
                $request->getLimit()
            )
        );

        return $this;
    }
425234
public function whereRaw(string $condition): self
    {
        $this->condition->where([new RawExp($condition)]);

        return $this;
    }
335917
public function setFieldQuery(string $field, string $query): self
    {
        return $this->setFieldParam($field, 'query', $query);
    }
1332937
public function setSelf($self)
    {
        $this->_links[self::SELF][self::HREF] = $self;
        $this->removeEmptyLinks();

        return $this;
    }
486031
public function setQuery($query = null)
    {

        try {

            // need to return << true
            $this->validator->verify($query, ['isNotNull', 'isAcceptLength']);

            if (false === $this->exact) {
                $this->query = ['query' => '%' . $query . '%'];
            }
            else {
                $this->query = ['query' => $query];
            }

        }
        catch(ExceptionFactory $e) {
            echo $e->getMessage();
        }

        return $this;
    }
1025188
private function setWhereAllCallback(QueryBuilder $qb)
    {
        if (!empty($this->callbacks['WhereAll'])) {
            foreach ($this->callbacks['WhereAll'] as $callback) {
                $callback($qb);
            }
        }

        return $this;
    }
857950
public function setDQL($dqlQuery)
    {
        if ($dqlQuery !== null) {
            $this->dql   = $dqlQuery;
            $this->state = self::STATE_DIRTY;
        }

        return $this;
    }