Return the filter applied to the query.

@return QueryInterface
324057
private function getQueryFilter()
    {
        $query = null;

        $this->category->setIsActive(true);

        if ($this->category->getIsVirtualCategory() || $this->category->getId()) {
            $query = $this->category->getVirtualRule()->getCategorySearchQuery($this->category);
        }

        if ((bool) $this->category->getIsVirtualCategory() === false) {
            $queryParams = [];

            if ($query !== null) {
                $queryParams['should'][] = $query;
            }

            $idFilters = [
                'should'  => $this->category->getAddedProductIds(),
                'mustNot' => $this->category->getDeletedProductIds(),
            ];

            foreach ($idFilters as $clause => $productIds) {
                if ($productIds && !empty($productIds)) {
                    $queryParams[$clause][] = $this->getEntityIdFilterQuery($productIds);
                }
            }

            $query = $this->queryFactory->create(QueryInterface::TYPE_BOOL, $queryParams);
        }

        return $query;
    }
1352535
public function getQuery()
    {
        $idField = $this->documentKey;

        if ($idField == null) {
            throw new QueryException('id should not be null');
        }

        $documentLimitation = $this->createFilterQuery('id')->setQuery(sprintf('id:%s', $idField));
        $this->addFilterQuery($documentLimitation);

        $this->setQuery('*:*');

        return parent::getQuery();
    }
951785
private function get_query_filter_name() {
		$filter_format = trim( $this->filter_format( $this->endpoint ), '_' );
		return sprintf( self::QUERY_FILTER, $filter_format );
	}
1027706
private function queryFilterRequest()
    {
        if (!$safeFilter = Request::get('filter')) {
            return false;
        }

        if (!isset($this->safeFilters()[$safeFilter])) {
            return false;
        }

        return $this->query = $this->filters()[$this->safeFilters()[$safeFilter]];
    }
643710
private function getSearchQuery()
    {
        $queries = [];

        foreach ($this->queryProviders as $queryProvider) {
            $queries[] = $queryProvider->getQuery();
        }

        return array_filter($queries);
    }
474801
public function getFilterManager()
    {
        if (!$this->filterManager) {
            $this->filterManager = $this->getServiceLocator()->get('HtImgModule\Imagine\Filter\FilterManager');
        }

        return $this->filterManager;
    }
225539
public function filtering()
    {
        $this->query->where(
                function ($query) {
            $globalKeyword = $this->setupKeyword($this->request->keyword());
            $queryBuilder  = $this->getQueryBuilder($query);
            if ($this->request->hasHeader('search-protection')) {
                $this->request->setSearchableColumnIndex($this->columns, $this->columnDef['filter']);
            }

            foreach ($this->request->searchableColumnIndex() as $index) {
                $columnName = $this->getColumnName($index);
                if ($this->isBlacklisted($columnName)) {
                    continue;
                }

                // check if custom column filtering is applied
                if (isset($this->columnDef['filter'][$columnName])) {
                    $columnDef         = $this->columnDef['filter'][$columnName];
                    // check if global search should be applied for the specific column
                    $applyGlobalSearch = count($columnDef['parameters']) == 0 || end($columnDef['parameters']) !== false;
                    if (!$applyGlobalSearch) {
                        continue;
                    }

                    if ($columnDef['method'] instanceof Closure) {
                        $whereQuery = $queryBuilder->newQuery();
                        call_user_func_array($columnDef['method'], [$whereQuery, $this->request->keyword()]);
                        $queryBuilder->addNestedWhereQuery($whereQuery, 'or');
                    } else {
                        $this->compileColumnQuery(
                                $queryBuilder, Helper::getOrMethod($columnDef['method']), $columnDef['parameters'], $columnName, $this->request->keyword()
                        );
                    }
                } else {
                    if (count(explode('.', $columnName)) > 1) {
                        $eagerLoads     = $this->getEagerLoads();
                        $parts          = explode('.', $columnName);
                        $relationColumn = array_pop($parts);
                        $relation       = implode('.', $parts);
                        if (in_array($relation, $eagerLoads)) {
                            $this->compileRelationSearch(
                                    $queryBuilder, $relation, $relationColumn, $globalKeyword
                            );
                        } else {
                            $this->compileGlobalSearch($queryBuilder, $columnName, $globalKeyword);
                        }
                    } else {
                        $this->compileGlobalSearch($queryBuilder, $columnName, $globalKeyword);
                    }
                }

                $this->isFilterApplied = true;
            }
        }
        );
    }
119316
protected function getCustomFilters()
    {
        $filters = (array) $this->getOption('custom_filters');

        return array_filter(
            $filters,
            function ($name) {
                return is_string($name);
            },
            ARRAY_FILTER_USE_KEY
        );
    }
705294
public function query()
    {
        $this->applyCriteria();

        if ($this->model instanceof Model) {
            return $this->model->query();
        }

        return clone $this->model;
    }
841031
public function getFilters()
    {
        $input = $this->collection->make(
            $this->request->except($this->sortName));

        $filters = $this->collection->make();

        $input->filter(function ($value) {
            if ($this->ignoreEmptyFilters && is_string($value) &&
                (string) $value == ''
            ) {
                return false;
            }

            return true;
        })->each(function ($value, $field) use ($filters) {
            $filter = new Filter();
            $filter->setField($field);
            $filter->setValue($value);
            $filters->push($filter);
        });

        return $filters;
    }
1354812
public function query()
    {
        $filters = [];
        $queries = [];

        foreach ($this->identity->getComps() as $comp) {
            if ($comp['value'] === null || (is_array($comp['value']) && empty($comp['value']))) {
                continue;
            }
            if ($comp['operator'] === Consts::WILDCARD) {
                $queries['bool']['must'][][Consts::WILDCARD][$comp['name']] = $comp['value'];
            } else {
                if ($comp['name'] === 'geo_distance') {
                    $filters[$comp['operator']][][$this->getTerm($comp['value'])] = $comp['value'];
                } else {
                    $filters[$comp['operator']][][$this->getTerm($comp['value'])][$comp['name']] = $comp['value'];
                }
            }
        }

        if (empty($queries)) {
            $queries = [
                'match_all' => [],
            ];
        }

        $result = $this->prepareType() + [
            'from'  => $this->offset($this->identity),
            'size'  => $this->limit($this->identity),
            'body'  => [
                'query' => [
                    'filtered' => [
                        'query' => $queries,
                        'filter' => [
                            'bool' => $filters,
                        ],
                    ],
                ],
                'sort' => $this->orderBy(),
            ]
        ];

        $groupBy = $this->groupBy();
        if (count($groupBy) > 0) {
            $result['body']['aggs'] = $groupBy;
            $result['size'] = 0;
        }

        return $result;
    }
728325
public function getFilterCollection()
    {
        if (null === $this->filterCollection) {
            $this->filterCollection = new Filter\FilterCollection($this);
        }

        return $this->filterCollection;
    }
194223
public function query()
    {
        $query = app($this->model)->query()->with(['ticketable']);

        return $this->applyScopes($query);
    }
18397
public function filter(ODataQueryFilterInterface $filter = NULL) {
        if (isset($filter)) {
            $this->setFilter($filter);
            return $this;
        }
        return $this->getFilter();
    }
98763
public function getQuery()
    {
        $query = $this->database->getSelectQuery()->from($this->table);

        foreach ($this->join as $join) {
            if (!is_array($join[2])) {
                $join[2] = [$join[2]];
            }

            $where = array_shift($join[2]);
            if (!empty($join[2])) {
                foreach ($join[2] as $i => $value) {
                    $join[2][$i] = $this->database->bind($value);
                }

                $where = vsprintf($where, $join[2]);
            }

            $query->join($join[0], $join[1], $where, $join[3]);
        }

        foreach ($this->filter as $i => $filter) {
            //array('post_id=%s AND post_title IN %s', 123, array('asd'));
            $where = array_shift($filter);
            if (!empty($filter)) {
                foreach ($filter as $i => $value) {
                    $filter[$i] = $this->database->bind($value);
                }

                $where = vsprintf($where, $filter);
            }

            $query->where($where);
        }

        return $query;
    }
381075
public function getFilteredValue()
    {
        if ($this->hasFilterer()) {
            $value = $this->getFilterer()->filter($this->getValue());
        } else {
            $value = $this->getValue();
        }

        return $value;
    }
703958
public function getFilter()
    {
        if ($this->filter) {
            return $this->filter;
        }

        $filterType = $this->getFilterType();

        if (!$filterType) {
            return false;
        }

        if (class_exists($filterType)) {
            $className = $filterType;
        } else {
            $className = str_replace('_', ' ', $filterType);
            $className = ucwords(strtolower($className));
            $className = str_replace(' ', '', $className);

            $className = 'PedroTeixeira\Bundle\GridBundle\Grid\Filter\\' . $className;
        }

        try {
            $reflection = new \ReflectionClass($className);

            $this->filter = $reflection->newInstance(
                $this->container
            );

            $this->filter->setIndex($this->getIndex());

            return $this->filter;

        } catch (\Exception $e) {
            throw new \Exception(
                sprintf('Grid column type "%s" doesn\'t exist', $filterType)
            );
        }
    }