/** * @param mixed $query * @param $fullResult (default = false) By default only the total hit count is returned. If set to true, the full ResultSet including aggregations is returned * * @return int|ResultSet */ public function count($query = '', $fullResult = false) { $this->setOptionsAndQuery(null, $query); $query = $this->getQuery(); $query->setSize(0); $path = $this->getPath(); $response = $this->getClient()->request($path, Request::GET, $query->toArray(), [self::OPTION_SEARCH_TYPE => self::OPTION_SEARCH_TYPE_QUERY_THEN_FETCH]); $resultSet = $this->_builder->buildResultSet($response, $query); return $fullResult ? $resultSet : $resultSet->getTotalHits(); }
/** * Runs any registered transformers on the ResultSet before * returning it, allowing the transformers to inject additional * data into each Result. * * @param Response $response * @param Query $query * * @return ResultSet */ public function buildResultSet(Response $response, Query $query) { $resultSet = $this->builder->buildResultSet($response, $query); $this->processor->process($resultSet); return $resultSet; }