Suggests a list of values for the given prefix.

@param string $prefix
@param string[] $fieldPaths
@param int $limit
@param \eZ\Publish\API\Repository\Values\Content\Query\Criterion $filter
18396
public function suggest($prefix, $fieldPaths = array(), $limit = 10, Criterion $filter = null)
    {
        return $this->service->suggest($prefix, $fieldPaths, $limit, $filter);
    }
800939
@Override
    public List<Metric> filter(Map<Metric, String> extendedSortedMap, String limit) {
        SystemAssert.requireArgument(extendedSortedMap != null && !extendedSortedMap.isEmpty(), "New map is not constructed successfully!");
        SystemAssert.requireArgument(limit != null && !limit.equals(""), "Limit must be provided!");

        List<Metric> result = new ArrayList<Metric>();

        for (Map.Entry<Metric, String> entry : extendedSortedMap.entrySet()) {
            if (Double.parseDouble(limit) > Double.parseDouble(entry.getValue())) {
                result.add(entry.getKey());
            }
        }
        return result;
    }
748204
protected function applyFormFilters(QueryBuilder $queryBuilder, array $filters = [])
    {
        foreach ($filters as $field => $listFilter) {
            if (null === $listFilter) {
                continue;
            }

            $this->filterQueryBuilder($queryBuilder, $field, $listFilter);
        }
    }
344246
public function search(string $term, int $limit = null, array $filters = [])
    {
        $filters_array = [];

        if ($filters) {
            $filters_array = [
                'filters' => $this->resolveFilters(__FUNCTION__, $filters),
            ];
        }

        $data = [
            'term' => $term,
            'limit' => $limit,
            'filters' => $filters,
        ];

        $data = array_merge($data, $filters_array);

        $url = self::$base_url.'/search?'.http_build_query($data);

        return self::$curl->get($url);
    }
19451
private function performSelectFromField($field, $prefix = 'u')
    {
        // Relation name and field delimited by underscore
        $fieldParts = explode('_', $field);

        // temporary variable for saving field name (needed for array results like [0])
        $realFieldName = $field;
        // check if a certain field number is searched
        if (preg_match('/^(.*)\[(\d+)\]$/', $fieldParts[0], $regresult)) {
            $fieldParts[0] = $regresult[1];
            $realFieldName = implode('_', $fieldParts);
            $this->relationalFilters[$realFieldName] = $regresult[2];
        }

        // If field is delimited and is a Relation
        if (count($fieldParts) >= 2 && $this->isRelation($fieldParts[0])) {
            $this->joins .= $this->generateJoins($fieldParts, $prefix);
            if (in_array($field, $this->fields)) {
                // last element is column name and next-to-last is the associationPrefix
                $i = count($fieldParts) - 1;

                // {associationPrefix}.{columnName} {alias}
                $parent = $fieldParts[$i - 1];
                $tempField = $fieldParts[$i];
                $alias = $realFieldName;

                $this->addToSelect($parent, $tempField, $alias);
            }
        } elseif (in_array($field, $this->fields) && in_array($field, $this->fieldNames)) {
            $this->addToSelect($prefix, $field);
        }
    }
929366
public function Where(string $filter, array $params = []): QueryBuilder
    {
        $this->filter;
        $this->params = $params;
        
        return $this;
    }
745871
private function applyFilters($filters = [], $returnCount = false)
    {
        $result = null;
        // Convert our filters into a query.
        if ($filters) {
            $alias = $this->getTableAlias();
            $query = $this->getEntityManager()->getConnection()->createQueryBuilder();
            if ($returnCount) {
                $query->select('COUNT(*)');
            } else {
                // Selecting only the id and contact_id for covering index benefits.
                $query->select($alias.'.id, '.$alias.'.contact_id');
                $query->setMaxResults(1);
            }
            $query->from(MAUTIC_TABLE_PREFIX.$this->getTableName(), $alias);

            foreach ($filters as $k => $set) {
                // Expect orx, anx, or neither.
                if (isset($set['orx'])) {
                    if (count($set['orx'])) {
                        $expr = $query->expr()->orX();
                    }
                    $properties = $set['orx'];
                } elseif (isset($set['andx'])) {
                    if (count($set['andx'])) {
                        $expr = $query->expr()->andX();
                    }
                    $properties = $set['andx'];
                } else {
                    $expr       = $query->expr();
                    $properties = $set;
                }
                if (isset($expr)) {
                    foreach ($properties as $property => $value) {
                        if (is_array($value)) {
                            $expr->add(
                                $query->expr()->in($alias.'.'.$property, $value)
                            );
                        } else {
                            $expr->add(
                                $query->expr()->eq($alias.'.'.$property, ':'.$property.$k)
                            );
                            $query->setParameter($property.$k, $value);
                        }
                    }
                }
                if (isset($set['date_added'])) {
                    $query->add(
                        'where',
                        $query->expr()->andX(
                            $query->expr()->gte($alias.'.date_added', 'FROM_UNIXTIME(:dateAdded'.$k.')'),
                            (isset($expr) ? $expr : null)
                        )
                    );
                    $query->setParameter('dateAdded'.$k, (int) $set['date_added']);
                }
                $result = $query->execute()->fetch();
                if ($returnCount) {
                    $result = intval(reset($result));
                }
            }
        }

        return $result;
    }
511633
private function applyCriteriaToQueryBuilder(Criteria $criteria, QueryBuilder $qb, $prefix)
    {
        if ($criteria->getMode() === Criteria::MODE_OR) {
            $expr = $qb->expr()->orX();
        } else {
            $expr = $qb->expr()->andX();
        }
        foreach ($criteria as $criterium) {
            if ($criterium instanceof Criteria) {
                $expr->add(
                    $this->applyCriteriaToQueryBuilder($criterium, $qb, $prefix)
                );
            } else {
                $this->applyCriteriumToQueryBuilder($criterium, $qb, $expr, $prefix);
            }
        }

        return $expr;
    }
277764
protected function eachValue(array $values, $prefix = null)
    {
        foreach ($values as $key => $value):
            if (is_array($value)):
                $this->eachValue($value, $key); else:
                if (is_numeric($key)):
                    $key = $prefix.$key; elseif (is_string($prefix)):
                    $key = $prefix.':'.$key;
        endif;

        $this->html[] = $this->makeTag($key, $value);
        endif;
        endforeach;
    }
98960
private function searchByProperties($propertyFilters, $rootClass, $offset, $limit)
    {
        // for searching by properties will be used RDF search
        $options = [
            'recursive' => true,
            'like'      => true,
            'limit'     => $limit,
            'offset'    => $offset
        ];
        $count = $rootClass->countInstances($propertyFilters, $options);
        $resources = $rootClass->searchInstances($propertyFilters, $options);
        return $this->format($resources, $count, $offset, $limit);
    }
358364
public function filterByPrefix(string $prefixFilter): ClassNameIndex
    {
        $pointcuts = array_keys($this->classNames);
        $result = new ClassNameIndex();

        $right = count($pointcuts) - 1;
        $left = 0;

        $found = false;
        $currentPosition = -1;
        while ($found === false) {
            if ($left > $right) {
                break;
            }
            $currentPosition = $left + floor(($right - $left) / 2);
            if (strpos($pointcuts[$currentPosition], $prefixFilter) === 0) {
                $found = true;
                break;
            } else {
                $comparisonResult = strcmp($prefixFilter, $pointcuts[$currentPosition]);
                if ($comparisonResult > 0) {
                    $left = $currentPosition + 1;
                } else {
                    $right = $currentPosition - 1;
                }
            }
        }

        if ($found === true) {
            $startIndex = $currentPosition;
            while ($startIndex >= 0 && strpos($pointcuts[$startIndex], $prefixFilter) === 0) {
                $startIndex--;
            }
            $startIndex++;
            $endIndex = $currentPosition;
            while ($endIndex < count($pointcuts) && strpos($pointcuts[$endIndex], $prefixFilter) === 0) {
                $endIndex++;
            }

            $result->setClassNames(array_slice($pointcuts, $startIndex, $endIndex - $startIndex));
        }
        return $result;
    }
565324
protected function filterLimitOffset(&$filter, $select)
    {
        $limit = null;
        $offset = null;

        if (array_key_exists('limit', $filter)) {
            $limit = (int) $filter['limit'];
            unset($filter['limit']);
        }
        if (array_key_exists('offset', $filter)) {
            $offset = (int) $filter['offset'];
            unset($filter['offset']);
        }
        $select->limit($limit, $offset);
    }
616254
public function makeTwigFilters($filters = [])
    {
        if (!is_array($filters)) {
            $filters = [];
        }

        foreach ($this->listFilters() as $name => $callable) {

            /*
             * Handle a wildcard function
             */
            if (strpos($name, '*') !== false && $this->isWildCallable($callable)) {
                $callable = function ($name) use ($callable) {
                    $arguments = array_slice(func_get_args(), 1);
                    $method = $this->isWildCallable($callable, Str::camel($name));
                    return call_user_func_array($method, $arguments);
                };
            }

            if (!is_callable($callable)) {
                throw new ApplicationException(sprintf('The markup filter for %s is not callable.', $name));
            }

            $filters[] = new Twig_SimpleFilter($name, $callable, ['is_safe' => ['html']]);
        }

        return $filters;
    }
972324
public function setFilters($filters, QueryBuilder &$query, QueryBuilder &$countQuery, &$selects)
    {
        //then we set the filters
        if ($filters && is_array($filters)) {
            foreach ($filters as $filter) {
                //get the field object
                $fieldObject = $this->fieldFactory->findFilter($filter['field_name']);

                //set the filter on the object
                $fieldObject->setFilter($filter);

                //filter the query objects, only pass in the selects the first time so they aren't added twice
                $fieldObject->filterQuery($query, $selects);
                $fieldObject->filterQuery($countQuery);
            }
        }
    }
1174381
public function toDynamoDbQuery(
        $columns = [],
        $limit = DynamoDbQueryBuilder::MAX_LIMIT
    ) {
        $this->applyScopes();

        $this->resetExpressions();

        $op = 'Scan';
        $queryBuilder = DynamoDb::table($this->model->getTable());

        if (! empty($this->wheres)) {
            $analyzer = $this->getConditionAnalyzer();

            if ($keyConditions = $analyzer->keyConditions()) {
                $op = 'Query';
                $queryBuilder->setKeyConditionExpression($this->keyConditionExpression->parse($keyConditions));
            }

            if ($filterConditions = $analyzer->filterConditions()) {
                $queryBuilder->setFilterExpression($this->filterExpression->parse($filterConditions));
            }

            if ($index = $analyzer->index()) {
                $queryBuilder->setIndexName($index->name);
            }
        }

        if ($this->index) {
            // If user specifies the index manually, respect that
            $queryBuilder->setIndexName($this->index);
        }

        if ($limit !== static::MAX_LIMIT) {
            $queryBuilder->setLimit($limit);
        }

        if (!empty($columns)) {
            // Either we try to get the count or specific columns
            if ($columns == ['count(*)']) {
                $queryBuilder->setSelect('COUNT');
            } else {
                $queryBuilder->setProjectionExpression($this->projectionExpression->parse($columns));
            }
        }

        if (!empty($this->lastEvaluatedKey)) {
            $queryBuilder->setExclusiveStartKey($this->lastEvaluatedKey);
        }

        $queryBuilder
            ->setExpressionAttributeNames($this->expressionAttributeNames->all())
            ->setExpressionAttributeValues($this->expressionAttributeValues->all());

        $raw = new RawDynamoDbQuery($op, $queryBuilder->prepare($this->client)->query);

        if ($this->decorator) {
            call_user_func($this->decorator, $raw);
        }

        return $raw;
    }
274416
public function filter($value, $pattern, $replacement = '', $limit = -1)
    {
        $this->assertNoEval($pattern);
        
        if (!isset($value)) {
            return null;
        }
        
        return preg_filter($pattern, $replacement, $value, $limit);
    }
17014
private function addToSelect($prefix, $field, $alias = '')
    {
        if (strlen($this->select) > 0) {
            $this->select .= ', ';
        }
        $this->select .= $this->generateSelect($prefix, $field, $alias);
    }