@param \Elastica\Query $query

@throws \InvalidArgumentException

@return \Elastica\Query\BoolQuery
347112
protected function getBoolQuery(Query $query): BoolQuery
    {
        $boolQuery = $query->getQuery();
        if (!$boolQuery instanceof BoolQuery) {
            throw new InvalidArgumentException(sprintf(
                'Localized query expander available only with %s, got: %s',
                BoolQuery::class,
                get_class($boolQuery)
            ));
        }

        return $boolQuery;
    }
385206
public function buildQuery($query)
    {
        $q = $this->request->getQuery();

        foreach ($query as $key => $value)
        {
            $q[$key] = $value;
        }
    }
854486
public function withQuery($query)
    {
        if (!is_string($query) && !method_exists($query, '__toString')) {
            throw new InvalidArgumentException('Uri query must be a string');
        }
        $query = ltrim((string)$query, '?');
        $clone = clone $this;
        $clone->query = Validator::checkQuery($query);

        return $clone;
    }
43464
protected function filterQuery($query)
    {
        $query = preg_replace_callback(
            '/(?:[^' . self::CHARACTERS_UNRESERVED . self::CHARACTERS_SUB_DELIMS . '%:@\/\?]+|%(?![A-Fa-f0-9]{2}))/',
            function ($match) {
                return rawurlencode($match[0]);
            },
            $query
        );

        if (is_null($query)) {
            throw new InvalidArgumentException(sprintf('Invalid query strings "%s".', $query));
        } elseif (!$query) {
            $query = '';
        }

        if (substr($query, 0, 1) === '?') {
            $query = substr($query, 1);
        }

        return $query;
    }
258264
public function merge(Query $query): Query
    {
        foreach ($query->getCriteria() as $criterion) {
            $criterion->attach($this);
        }

        return $this->attach($query);
    }
1037099
public function query($query) {
		$args = func_get_args();
		$query = array_shift($args);
		return $this->execute($query, $args);
	}
151560
public function findSlugged(Query $query, array $options) {
		if (empty($options['slug'])) {
			throw new InvalidArgumentException("The 'slug' key is required for find('slugged')");
		}

		return $query->where([$this->_config['field'] => $options['slug']]);
	}
1166128
protected function setQuery($query)
    {
        $this->uriString = null;

        $query = ltrim($query, '?');

        if (strpos($query, '#') !== false) {
            throw new InvalidArgumentException(
                'Query string must not include a URI fragment.'
            );
        }

        $this->query = static::encode($query);

        return $this;
    }
683315
public function addQuery($args): self
    {
        if (!\is_array($args) && !($args instanceof AbstractQuery)) {
            throw new InvalidException('Invalid parameter. Has to be array or instance of Elastica\Query\AbstractQuery');
        }

        return $this->addParam('queries', $args);
    }
3192
public function setQuery($query)
    {
        if (is_string($query)) {
            $output = null;
            parse_str($query, $output);
            $this->query = new QueryString($output);
        } elseif (is_array($query)) {
            $this->query = new QueryString($query);
        } elseif ($query instanceof QueryString) {
            $this->query = $query;
        }

        return $this;
    }
449416
public function queryWith(QueryInterface $query)
    {
        $this->query($query);
        $queryBuilder = $query->build();

        return $this->findWith($queryBuilder);
    }
194122
public function setQuery($query)
    {
        if ($query instanceof Query) {
            $this->query = $query;
        } elseif (is_string($query)) {
            $this->query = Query::fromString($query);
        } elseif (is_array($query)) {
            $this->query = new Query($query);
        } else {
            throw new \InvalidArgumentException('Query must be a '
                . 'QueryInterface, array, or string');
        }

        return $this;
    }
649902
public function validateQuery($query)
    {
        if (!is_string($query) && !method_exists($query, '__toString')) {
            throw new InvalidArgumentException(
                'Query must be a string'
            );
        }

        if (strpos($query, '#') !== false) {
            throw new InvalidArgumentException(
                'Query must not contain a URI fragment'
            );
        }
    }
29989
public function rawQuery($query = '')
    {
        if (! \is_string($query)) {
            throw InvalidArgumentPassedException::isNotString();
        }

        $total = $this->totalQueries();

        $this->queries[$total] = \trim($query);
    }
271226
public function setQuery($query)
    {
        if (!empty($query)) {
            $this->data['query'] = $this->_queryToArray($query);
        }

        return $this;
    }
1374911
public function setQuery($query)
    {
        if (!($query instanceof QueryString)) {
            $this->query = new QueryString($query);

            return $this;
        }

        $this->query = $query;

        return $this;
    }
5326
public function doQuery($query)
    {
        $this->statement = $this->db->query($query);
        if ($this->statement && $this->statement->rowCount()) {
            return $this->statement->rowCount();
        }
        return false;
    }